Skip to content

Instantly share code, notes, and snippets.

@engie
Created August 25, 2012 18:09
Show Gist options
  • Save engie/3468687 to your computer and use it in GitHub Desktop.
Save engie/3468687 to your computer and use it in GitHub Desktop.
Use std::move to abandon ownership
#include <memory>
class A
{
public:
A( std::unique_ptr< int > v ) : m_v( std::move(v) ) {}
std::unique_ptr< int > m_v;
};
int main( int argc, char** argv )
{
std::unique_ptr< int > i( new int(10) );
A a( std::move(i) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment