Skip to content

Instantly share code, notes, and snippets.

@Asher-
Created March 2, 2017 21:43
Show Gist options
  • Select an option

  • Save Asher-/a8d31c619c7652fc931301ad11262a36 to your computer and use it in GitHub Desktop.

Select an option

Save Asher-/a8d31c619c7652fc931301ad11262a36 to your computer and use it in GitHub Desktop.
template
<
typename Type
>
class ReseatableReference
{
public:
ReseatableReference ( const Type& reference ) : reference( reference ) {};
void set( const Type& reference ) { ~ReseatableReference(); new (this) ReseatableReference( reference ); }
Type& operator()() { return reference; };
operator Type&() { return reference; };
const Type& reference;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment