Last active
June 22, 2021 04:46
-
-
Save recuraki/96a575f93723734cef6db982de3c2481 to your computer and use it in GitHub Desktop.
boostでのsplit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| #include <boost/algorithm/string/classification.hpp> // is_any_of | |
| #include <boost/algorithm/string/split.hpp> | |
| #include <boost/range/algorithm/for_each.hpp> | |
| using namespace std; | |
| void test(string s){ | |
| vector<std::string> result; | |
| cout << "Parse STR: \"" << s << "\"\n"; | |
| boost::algorithm::split(result, s, boost::is_any_of(",")); | |
| cout << " result array size: " << result.size() << "\n"; | |
| for(int i=0; i < (int)result.size(); i++){ | |
| cout << " array[i=" << i << "] size: " << result[i].size() << "\n"; | |
| } | |
| } | |
| int main() | |
| { | |
| test("1,2,3"); | |
| test("1"); | |
| test(","); | |
| test(""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment