Optional type - Don't use target() in operators
This commit is contained in:
parent
e2f548d55e
commit
ed126a2d5e
1 changed files with 4 additions and 4 deletions
|
@ -891,7 +891,7 @@ template< typename T >
|
|||
inline T const& T_Optional< T >::operator*( ) const
|
||||
{
|
||||
if ( present_ ) {
|
||||
return *target( );
|
||||
return *reinterpret_cast< T const* >( &storage_ );
|
||||
}
|
||||
throw std::bad_cast( );
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ template< typename T >
|
|||
inline T& T_Optional< T >::operator*( )
|
||||
{
|
||||
if ( present_ ) {
|
||||
return *target( );
|
||||
return *reinterpret_cast< T* >( &storage_ );
|
||||
}
|
||||
throw std::bad_cast( );
|
||||
}
|
||||
|
@ -909,7 +909,7 @@ template< typename T >
|
|||
inline T const* T_Optional< T >::operator->( ) const
|
||||
{
|
||||
if ( present_ ) {
|
||||
return target( );
|
||||
return reinterpret_cast< T const* >( &storage_ );
|
||||
}
|
||||
throw std::bad_cast( );
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ template< typename T >
|
|||
inline T* T_Optional< T >::operator->( )
|
||||
{
|
||||
if ( present_ ) {
|
||||
return target( );
|
||||
return reinterpret_cast< T* >( &storage_ );
|
||||
}
|
||||
throw std::bad_cast( );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue