Skip to content

Instantly share code, notes, and snippets.

@Cryolite
Created March 2, 2012 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cryolite/1958552 to your computer and use it in GitHub Desktop.
Save Cryolite/1958552 to your computer and use it in GitHub Desktop.
#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