Created
January 28, 2014 11:02
-
-
Save sftrabbit/8665717 to your computer and use it in GitHub Desktop.
C++ Reference Binding
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> | |
std::string modifiable_rvalue() { | |
return "foo"; | |
} | |
const std::string const_rvalue() { | |
return "bar"; | |
} | |
int main() { | |
std::string modifiable_lvalue("baz"); | |
const std::string const_lvalue("qux"); | |
std::string& a = modifiable_lvalue; | |
//std::string& b = const_lvalue; // ERROR | |
//std::string& c = modifiable_rvalue(); // ERROR | |
//std::string& d = const_rvalue(); // ERROR | |
const std::string& e = modifiable_lvalue; | |
const std::string& f = const_lvalue; | |
const std::string& g = modifiable_rvalue(); | |
const std::string& h = const_rvalue(); | |
//std::string&& i = modifiable_lvalue; // ERROR | |
//std::string&& j = const_lvalue; // ERROR | |
std::string&& k = modifiable_rvalue(); | |
//std::string&& l = const_rvalue(); // ERROR | |
//const std::string&& m = modifiable_lvalue; // ERROR | |
//const std::string&& n = const_lvalue; // ERROR | |
const std::string&& o = modifiable_rvalue(); | |
const std::string&& p = const_rvalue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment