Since I couldn\'t find anything on this in the documentation, I thought I ask it here. I have the following program (C++11):
#include
#inc
boost::split always returns n + 1 tokens where n is number of separators in the input string. So don't be surprised when it returns 1 token when you pass it an empty string.
The rationale behind it is quite simple. Imagine that you are parsing a CSV file. You need to get the exactly same number of elements regardless whether the last token is empty or not.
It is much easier to remove the empty tokens than to guess whether they were supposed to be in the result or not. Credit
This behaviour is similar to python
>>> len("".split(','))
1