Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <boost/utility/string_view.hpp>
- class SomeClass {
- public:
- boost::string_view strView;
- std::string str;
- };
- void SomeFunction(SomeClass& someCopy) {
- SomeClass original;
- original.str = "Original string";
- original.strView = original.str;
- std::cout << "Original string = " << original.str << std::endl;
- std::cout << "Original string view = " << original.strView << std::endl;
- someCopy = original;
- }
- int main() {
- SomeClass someClass;
- SomeFunction(someClass);
- std::cout << "Copied string = " << someClass.str << std::endl;
- // The next string won't work correctly.
- std::cout << "Copied string view = " << someClass.strView << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement