Created
March 18, 2018 18:49
-
-
Save martenlienen/a169e6455f06e4e73f6de7ae0468b02d to your computer and use it in GitHub Desktop.
rvalue method and move assignment shenanigans
This file contains 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 <iostream> | |
#include <string> | |
class Message { | |
public: | |
Message &operator=(const std::string &&msg) && { | |
std::cout << msg << std::endl; | |
return *this; | |
} | |
}; | |
int main(int argc, char **argv) { | |
Message() = std::string("Hello, world!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment