Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50351 - trunk/boost/test
From: gennadiy.rozental_at_[hidden]
Date: 2008-12-22 02:50:23


Author: rogeeff
Date: 2008-12-22 02:50:22 EST (Mon, 22 Dec 2008)
New Revision: 50351
URL: http://svn.boost.org/trac/boost/changeset/50351

Log:
made convertible to bool
Text files modified:
   trunk/boost/test/predicate_result.hpp | 5 +++++
   1 files changed, 5 insertions(+), 0 deletions(-)

Modified: trunk/boost/test/predicate_result.hpp
==============================================================================
--- trunk/boost/test/predicate_result.hpp (original)
+++ trunk/boost/test/predicate_result.hpp 2008-12-22 02:50:22 EST (Mon, 22 Dec 2008)
@@ -41,6 +41,9 @@
 
 class BOOST_TEST_DECL predicate_result {
     typedef unit_test::const_string const_string;
+ struct dummy { void nonnull() {}; };
+ typedef void (dummy::*safe_bool)();
+
 public:
     // Constructor
     predicate_result( bool pv_ )
@@ -50,8 +53,10 @@
     template<typename BoolConvertable>
     predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
 
+ // Access methods
     bool operator!() const { return !p_predicate_value; }
     void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
+ operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
 
     // Public properties
     BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk