Skip to content

Instantly share code, notes, and snippets.

@ThePhD
Created June 17, 2014 21:02
Show Gist options
  • Save ThePhD/93fecc336fbae15c760c to your computer and use it in GitHub Desktop.
Save ThePhD/93fecc336fbae15c760c to your computer and use it in GitHub Desktop.
T& value( ) const {
typedef decltype( std::addressof( storage ) ) storage_address_t;
typedef typename std::conditional<std::is_const<T>::value, const void, void>::type void_t;
typedef typename std::remove_const<storage_address_t>::type address_t;
return *static_cast<T*>( static_cast<void_t*>( const_cast<address_t>( std::addressof( storage ) ) ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment