Last active
March 25, 2017 01:08
-
-
Save muaddib1971/3a45f5ff3a4d409c21243c5ebeb176ed to your computer and use it in GitHub Desktop.
An example of moving from a const reference and what that does to the original variable
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 <string> | |
| #include <iostream> | |
| #include <cstdlib> | |
| void moveit(std::string& s) | |
| { | |
| std::string mys = std::move(s); | |
| } | |
| int main(void) | |
| { | |
| std::string s = "hi"; | |
| std::cout << s << std::endl; | |
| moveit(s); | |
| std::cout << "after move"<<std::endl; | |
| std::cout << s << std::endl; | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment