Boost имеет сильную функцию разделения: boost :: algorithm :: split .
Пример программы:
#include
#include
int main() {
auto s = "a,b, c ,,e,f,";
std::vector fields;
boost::split(fields, s, boost::is_any_of(","));
for (const auto& field : fields)
std::cout << "\"" << field << "\"\n";
return 0;
}
Выход:
"a"
"b"
" c "
""
"e"
"f"
""