Optional type - Don't use target() in operators

This commit is contained in:
Emmanuel BENOîT 2018-12-15 20:40:14 +01:00
parent e2f548d55e
commit ed126a2d5e

View file

@ -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( );
}