00001 00006 /*----------------------------------------------------------------------------*/ 00007 /* C Tool Box: Designed and implemented by: */ 00008 /* Walter F.J. Mueller Gesellschaft fuer Schwerionenforschung (GSI) */ 00009 /* Planckstrasse 1, D-64291 Darmstadt, Germany */ 00010 /* Email: W.F.J.Mueller@gsi.de */ 00011 /* WWW: http://www-kp3.gsi.de/www/kp3/people/mueller.html */ 00012 /*------------------------------------------+---------------------------------*/ 00013 00022 //------------------------------------------+----------------------------------- 00024 00025 template<class T> 00026 inline CTBfallible<T>::CTBfallible() 00027 : CTBfallibleBase(false) 00028 {} 00029 00030 //------------------------------------------+----------------------------------- 00032 00033 template<class T> 00034 inline CTBfallible<T>::CTBfallible(const T& value) 00035 : CTBfallibleBase(true), 00036 m_value(value) 00037 {} 00038 00039 //------------------------------------------+----------------------------------- 00041 00042 template<class T> 00043 inline CTBfallible<T>::operator T() const 00044 { 00045 if (Failed()) ThrowError(); 00046 return m_value; 00047 } 00048 00049 //------------------------------------------+----------------------------------- 00051 00052 template<class T> 00053 inline T CTBfallible<T>::ElseDefaultTo(const T& default_value) 00054 { 00055 return Valid() ? m_value : default_value; 00056 }