Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string line; // cannot be const
- std::getline(std::cin, line);
- // line should be const from here on out
- std::string f1();
- std::string f2(std::string s);
- std::string f3() {
- const std::string s = f1(); // s is not meant to be modified
- // but I still want the move optimization here:
- const std::string result = f2(std::move(s)); // this doesn't move
- // and I want the compiler to move out here:
- return result; // this will probably RVO, but if not, the move
- // constructor will not be used due to the const
- }
Add Comment
Please, Sign In to add comment