diff options
| author | Mickey Rose | 2017-01-19 15:04:54 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-01-19 21:25:27 +0100 |
| commit | 227598af47e4d46f06cfcc879f206eb34e681275 (patch) | |
| tree | bb9d9d1a23ac454df82dff4f70026484c0d1cb68 /include | |
| parent | cfaf906417ad575f075e83926d7726d2963a7104 (diff) | |
| download | catch3-227598af47e4d46f06cfcc879f206eb34e681275.tar.gz | |
use sizeof(expr) for unevaluated syntax check
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_capture.hpp | 3 | ||||
| -rw-r--r-- | include/internal/catch_common.h | 5 |
2 files changed, 3 insertions, 5 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 902c6288..0be1b8ee 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -40,8 +40,7 @@ __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \ } \ INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look - // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. + } while( Catch::alwaysFalse( sizeof(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 9e742bc4..0104b539 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -116,9 +116,8 @@ namespace Catch { std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); // This is just here to avoid compiler warnings with macro constants and boolean literals - inline bool isTrue( bool value ){ return value; } - inline bool alwaysTrue() { return true; } - inline bool alwaysFalse() { return false; } + inline bool alwaysTrue( std::size_t = 0 ) { return true; } + inline bool alwaysFalse( std::size_t = 0 ) { return false; } void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); |