Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <utility>
- // using std::move
- #include <string>
- // using std::string
- #include <cstdio>
- // using std::printf
- namespace {
- # ifdef WITH_CONST_RREF
- void print(const std::string&& str)
- {
- std::printf("Copy const rref %s\n", str.c_str());
- }
- # endif /* WITH_CONST_RREF */
- void print(const std::string& str)
- {
- std::printf("Copy %s\n", str.c_str());
- }
- void print(std::string&& str)
- {
- std::printf("Move %s\n", str.c_str());
- }
- void move_to_print(const std::string& str)
- {
- print(std::move(str));
- }
- }
- int main()
- {
- std::string foo("foo");
- move_to_print(foo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment