diff options
Diffstat (limited to 'shared/loki/CheckReturn.h')
-rw-r--r-- | shared/loki/CheckReturn.h | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/shared/loki/CheckReturn.h b/shared/loki/CheckReturn.h index fbe63ed0..c0a65aa5 100644 --- a/shared/loki/CheckReturn.h +++ b/shared/loki/CheckReturn.h @@ -65,46 +65,46 @@ namespace Loki template<class T> struct IgnoreReturnValue { - static void run(const T&) - { - /// Do nothing at all. - } + static void run(const T&) + { + /// Do nothing at all. + } }; template<class T> struct ThrowTheValue { - static void run(const T & value ) - { - throw value; - } + static void run(const T& value ) + { + throw value; + } }; template<class T> struct ThrowLogicError { - static void run( const T & ) - { - throw ::std::logic_error( "CheckReturn: return value was not checked.\n" ); - } + static void run( const T& ) + { + throw ::std::logic_error( "CheckReturn: return value was not checked.\n" ); + } }; template<class T> struct TriggerAssert { - static void run(const T&) - { - assert( 0 ); - } + static void run(const T&) + { + assert( 0 ); + } }; template<class T> struct FprintfStderr { - static void run(const T&) - { - fprintf(stderr, "CheckReturn: return value was not checked.\n"); - } + static void run(const T&) + { + fprintf(stderr, "CheckReturn: return value was not checked.\n"); + } }; @@ -114,45 +114,45 @@ class CheckReturn { public: - /// Conversion constructor changes Value type to CheckReturn type. - inline CheckReturn( const Value & value ) : - m_value( value ), m_checked( false ) {} - - /// Copy-constructor allows functions to call another function within the - /// return statement. The other CheckReturn's m_checked flag is set since - /// its duty has been passed to the m_checked flag in this one. - inline CheckReturn( const CheckReturn & that ) : - m_value( that.m_value ), m_checked( false ) - { that.m_checked = true; } - - /// Destructor checks if return value was used. - inline ~CheckReturn( void ) - { - // If m_checked is false, then a function failed to check the - // return value from a function call. - if (!m_checked) - OnError<Value>::run(m_value); - } - - /// Conversion operator changes CheckReturn back to Value type. - inline operator Value ( void ) - { - m_checked = true; - return m_value; - } + /// Conversion constructor changes Value type to CheckReturn type. + inline CheckReturn( const Value& value ) : + m_value( value ), m_checked( false ) {} + + /// Copy-constructor allows functions to call another function within the + /// return statement. The other CheckReturn's m_checked flag is set since + /// its duty has been passed to the m_checked flag in this one. + inline CheckReturn( const CheckReturn& that ) : + m_value( that.m_value ), m_checked( false ) + { that.m_checked = true; } + + /// Destructor checks if return value was used. + inline ~CheckReturn( void ) + { + // If m_checked is false, then a function failed to check the + // return value from a function call. + if (!m_checked) + OnError<Value>::run(m_value); + } + + /// Conversion operator changes CheckReturn back to Value type. + inline operator Value ( void ) + { + m_checked = true; + return m_value; + } private: - /// Default constructor not implemented. - CheckReturn( void ); + /// Default constructor not implemented. + CheckReturn( void ); - /// Copy-assignment operator not implemented. - CheckReturn & operator = ( const CheckReturn & that ); + /// Copy-assignment operator not implemented. + CheckReturn& operator = ( const CheckReturn& that ); - /// Copy of returned value. - Value m_value; + /// Copy of returned value. + Value m_value; - /// Flag for whether calling function checked return value yet. - mutable bool m_checked; + /// Flag for whether calling function checked return value yet. + mutable bool m_checked; }; // ---------------------------------------------------------------------------- |