Created
March 2, 2012 14:02
-
-
Save Cryolite/1958552 to your computer and use it in GitHub Desktop.
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> | |
struct S | |
{ | |
S(int i) : i_(i) {} | |
S(S const &) = delete; | |
S(S &&) = delete; | |
void double_() { i_ *= 2; } | |
int get() const { return i_; } | |
int i_; | |
}; | |
S f() | |
{ | |
return { 42 }; | |
} | |
S g() | |
{ | |
return { f().get() }; | |
} | |
S h() | |
{ | |
S &&r = g(); | |
r.double_(); | |
return { r.get() }; | |
} | |
int main() | |
{ | |
S const &r = h(); | |
std::cout << r.get() << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment