Skip to content

Instantly share code, notes, and snippets.

@puremourning
Created January 6, 2018 00:36
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 puremourning/b2123b8760cecbaf3c2e09776390620f to your computer and use it in GitHub Desktop.
Save puremourning/b2123b8760cecbaf3c2e09776390620f to your computer and use it in GitHub Desktop.
copy reference
// Example program
#include <iostream>
#include <string>
struct nocopy {
nocopy(int i_) : i(i_) {}
nocopy( const nocopy& ) = delete;
int i;
};
struct test {
test( nocopy& n_ ) : n( n_ ) {}
test( const test& other ): n(other.n) {}
nocopy& n;
};
int main()
{
nocopy n{ 1 };
test t{ n };
test t1{ t };
std::cout << "I: " << t1.n.i << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment