Skip to content

Instantly share code, notes, and snippets.

@martenlienen
Created March 18, 2018 18:49
Show Gist options
  • Save martenlienen/a169e6455f06e4e73f6de7ae0468b02d to your computer and use it in GitHub Desktop.
Save martenlienen/a169e6455f06e4e73f6de7ae0468b02d to your computer and use it in GitHub Desktop.
rvalue method and move assignment shenanigans
#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