Increase Separation Line

How can you split without creating strings?

+4
source share
3 answers

You can use std::regex as defined in C ++ 0x or in C ++ 98 TR1 - this returns iterators to the string (well, behind the facade anyway) - so this is not related to copying the string. The C ++ 0x regex option supports both extraction of matches and separation (extraction of inconsistencies) - so this is a complete replacement for strtok with a lot of extra power.

See the John Cook webpage , such as wikipedia or the Stephan T Lavavej video . You may need to use boost :: regex until C ++ 0x is more widely implemented; these two are compatible.

+1
source

Using Boost Split, you cannot. An obvious (but ugly) way to split strings without copying them would be strtok (or, preferably, strtok_s ).

0
source

You can use a receiver, akin to llvm::StringRef , which is just a pointer to a char array and size, and does not provide the mutator with a basic sequence.

However, this would mean transcoding separate logic onto itself.

0
source

Source: https://habr.com/ru/post/1337578/


All Articles