因为我无法在中找到这样的东西的文档 ,我以为我问在这里。 我有以下程序(C ++ 11):
#include <iostream>
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace boost;
int main () {
string tmp = " #tag #tag1#tag2 #tag3 ####tag4 ";
list<iterator_range<string::iterator> > matches;
split( matches, tmp, is_any_of("\t #"), token_compress_on );
for( auto match: matches ) {
cout << "'" << match << "'\n";
}
}
输出是:
''
'tag'
'tag1'
'tag2'
'tag3'
'tag4'
''
我本来以为在token_compress_on
选项删除所有空令牌。 该解决方案是,例如,使用boost::trim_if
。 不过,我想知道,这是升压::分裂的期望的行为,以及为什么发生这种情况?
(克++ 4.6.3,升压1.48)