From 0ecd4269ceddb96f33812bef9bedce90009444c3 Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Wed, 28 Jan 2009 18:12:10 +0000 Subject: [PATCH] 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 --- include/loki/CheckReturn.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/loki/CheckReturn.h b/include/loki/CheckReturn.h index 32171a3..4c136da 100755 --- a/include/loki/CheckReturn.h +++ b/include/loki/CheckReturn.h @@ -60,34 +60,36 @@ namespace Loki //////////////////////////////////////////////////////////////////////////////// +template struct IgnoreReturnValue { - static void run() + static void run(const T&) { /// Do nothing at all. } }; - +template struct TriggerAssert { - static void run() + static void run(const T&) { assert( 0 ); } }; - +template struct FprintfStderr { - static void run() + static void run(const T&) { fprintf(stderr, "CheckReturn: return value was not checked\n"); } }; -template < class Value , typename OnError = TriggerAssert> + +template < class Value , template class OnError = TriggerAssert > class CheckReturn { public: @@ -109,7 +111,7 @@ public: // If m_checked is false, then a function failed to check the // return value from a function call. if (!m_checked) - OnError::run(); + OnError::run(m_value); } /// Conversion operator changes CheckReturn back to Value type.