Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string_view>
- #include <vector>
- using namespace std;
- vector<string_view> SplitIntoWordsView(string_view str) {
- vector<string_view> result;
- //int64_t pos = 0;
- const int64_t pos_end = str.npos;
- while (true) {
- int64_t space = str.find(' ', 0);
- result.push_back(space == pos_end ? str.substr(0) : str.substr(0, space - 0));
- if (space == pos_end) {
- break;
- } else {
- str.remove_prefix(space + 1);
- }
- }
- return result;
- }
- int main() {
- auto answer = SplitIntoWordsView("saga; sa;a aasdf se ");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement