Tuesday, March 25, 2014

Using C++11 to split strings without using the boost library

Recently I did the StringCalculator kata in C++.

In order to be able to split a string using several alternative delimiters of one or more characters I used the following function: which is using several functions from the boost library: boost::algorithm::split_regex, boost::regex and boost::join.

Yesterday I managed to use some C++11 features to get the same functionality without using the boost library. This is the resulting code which uses C++11 regex and lambdas: These are the StringUtils tests where you can see how the split and join functions work: You can find all the code in this repository.

No comments:

Post a Comment