diff options
| author | Phil Nash | 2013-04-22 18:55:12 +0100 |
|---|---|---|
| committer | Phil Nash | 2013-04-22 18:55:12 +0100 |
| commit | 471eba2c32abe6811cdc2acddfbeb0032d0b5fe9 (patch) | |
| tree | 1152c26f3364b4a28775a964342e34d2231f1777 /include | |
| parent | 4dd3f68dd930fdb9f26c1776118e663908864931 (diff) | |
| download | catch3-471eba2c32abe6811cdc2acddfbeb0032d0b5fe9.tar.gz | |
Build 36
- incorporation of pull request #154 to allow comparison with nullptr_t
- some compiler capability tweaks
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_evaluate.hpp | 30 | ||||
| -rw-r--r-- | include/internal/catch_interfaces_reporter.h | 1 | ||||
| -rw-r--r-- | include/internal/catch_version.hpp | 2 |
3 files changed, 25 insertions, 8 deletions
diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 5971022a..db1be5ee 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -33,6 +33,14 @@ namespace Internal { template<> struct OperatorTraits<IsLessThanOrEqualTo> { static const char* getName(){ return "<="; } }; template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } }; + template<typename T> + inline T& opCast(const T& t) { return const_cast<T&>(t); } + +// nullptr_t support based on pull request #154 from Konstantin Baumann +#ifdef CATCH_CONFIG_CPP11_NULLPTR + inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } +#endif // CATCH_CONFIG_CPP11_NULLPTR + // So the compare overloads can be operator agnostic we convey the operator as a template // enum, which is used to specialise an Evaluator for doing the comparison. @@ -42,37 +50,37 @@ namespace Internal { template<typename T1, typename T2> struct Evaluator<T1, T2, IsEqualTo> { static bool evaluate( const T1& lhs, const T2& rhs) { - return const_cast<T1&>( lhs ) == const_cast<T2&>( rhs ); + return opCast( lhs ) == opCast( rhs ); } }; template<typename T1, typename T2> struct Evaluator<T1, T2, IsNotEqualTo> { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast<T1&>( lhs ) != const_cast<T2&>( rhs ); + return opCast( lhs ) != opCast( rhs ); } }; template<typename T1, typename T2> struct Evaluator<T1, T2, IsLessThan> { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast<T1&>( lhs ) < const_cast<T2&>( rhs ); + return opCast( lhs ) < opCast( rhs ); } }; template<typename T1, typename T2> struct Evaluator<T1, T2, IsGreaterThan> { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast<T1&>( lhs ) > const_cast<T2&>( rhs ); + return opCast( lhs ) > opCast( rhs ); } }; template<typename T1, typename T2> struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast<T1&>( lhs ) >= const_cast<T2&>( rhs ); + return opCast( lhs ) >= opCast( rhs ); } }; template<typename T1, typename T2> struct Evaluator<T1, T2, IsLessThanOrEqualTo> { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast<T1&>( lhs ) <= const_cast<T2&>( rhs ); + return opCast( lhs ) <= opCast( rhs ); } }; @@ -149,6 +157,16 @@ namespace Internal { template<Operator Op, typename T> bool compare( T* lhs, int rhs ) { return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); } + +#ifdef CATCH_CONFIG_CPP11_NULLPTR + // pointer to nullptr_t (when comparing against nullptr) + template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) { + return Evaluator<T*, T*, Op>::evaluate( NULL, rhs ); + } + template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) { + return Evaluator<T*, T*, Op>::evaluate( lhs, NULL ); + } +#endif // CATCH_CONFIG_CPP11_NULLPTR } // end of namespace Internal } // end of namespace Catch diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 856b33fc..3fa228b3 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -189,7 +189,6 @@ namespace Catch bool aborting; }; - // !Work In progress struct IStreamingReporter : IShared { virtual ~IStreamingReporter(); diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 5c5f4ccd..05478a72 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 0, 9, 35, "integration" ); + Version libraryVersion( 0, 9, 36, "integration" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED |