Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- void TestItOperator(const std::string& str, int length)
- {
- auto it = str.begin();
- auto chopped1 = std::string(it, it += length);
- auto chopped2 = std::string(str.begin(), it);
- auto chopped3 = std::string(str.begin(), str.begin() + length);
- std::cout << "Orig: " << str << std::endl;
- std::cout << "Chop1: " << chopped1 << std::endl;
- std::cout << "Chop2: " << chopped2 << std::endl;
- std::cout << "Chop3: " << chopped2 << std::endl;
- }
- int main()
- {
- TestItOperator("foobar", 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement