3 ms·
"C++47: Finally, a Standard Way to Split a String by Delimiter"
by semiinfinitely 7mo ago
"C++47: Finally, a Standard Way to Split a String by Delimiter"
- porise 7mo agoI'm still waiting for C++ to support Unicode properly.
- einpoklum 7mo agoA standard way to split a string? Well, what's wrong with: std::views::split(my_string, delimeter) ?
- nananana9 7mo agoTemplate bloat, terrible compile errors, terrible debug build performance, 1 second of extra compile time per cpp file when you include ranges, and you can't step through it in a debugger.
- fc417fc802 7mo ago> you can't step through it in a debugger. What do you mean by that?
- einpoklum 7mo agoNone of these complaints detract from this being a terse, readable, and available using the standard library, which is what the question was about... I will agree that std::ranges is quite a jumble of templates, and has a compilation time penalty. Perhaps the use of modules will help with that somewhat.
- MathMonkeyMan 7mo agoThere's been this since 1998, likely earlier: std::vector<std::string> split(const std::string& text, char delimiter) { std::vector<std::string> parts; std::istringstream stream(text); std::string part; while (std::getline(stream, part, delimiter)) { parts.push_back(part); } return parts; }