Add Rich's idea to pass the value into the policy

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@954 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2009-01-28 18:12:10 +00:00
parent c6c68b8391
commit 0ecd4269ce

View file

@ -60,34 +60,36 @@ namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class T>
struct IgnoreReturnValue struct IgnoreReturnValue
{ {
static void run() static void run(const T&)
{ {
/// Do nothing at all. /// Do nothing at all.
} }
}; };
template<class T>
struct TriggerAssert struct TriggerAssert
{ {
static void run() static void run(const T&)
{ {
assert( 0 ); assert( 0 );
} }
}; };
template<class T>
struct FprintfStderr struct FprintfStderr
{ {
static void run() static void run(const T&)
{ {
fprintf(stderr, "CheckReturn: return value was not checked\n"); fprintf(stderr, "CheckReturn: return value was not checked\n");
} }
}; };
template < class Value , typename OnError = TriggerAssert>
template < class Value , template<class> class OnError = TriggerAssert >
class CheckReturn class CheckReturn
{ {
public: public:
@ -109,7 +111,7 @@ public:
// If m_checked is false, then a function failed to check the // If m_checked is false, then a function failed to check the
// return value from a function call. // return value from a function call.
if (!m_checked) if (!m_checked)
OnError::run(); OnError<Value>::run(m_value);
} }
/// Conversion operator changes CheckReturn back to Value type. /// Conversion operator changes CheckReturn back to Value type.