mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Revert "use sizeof(expr) for unevaluated syntax check"
Using sizeof(expr) can trigger a compile-time error,
"lambda expressions are not allowed in an unevaluated context", when passing
expression containing lambda, like a std algorithm. This error is considered
a standard defect, as it is meant to prevent lambdas in decltype
or templates, but not in sizeof.
This reverts commit 227598af47.
			
			
This commit is contained in:
		| @@ -40,7 +40,8 @@ | |||||||
|             __catchResult.useActiveException( resultDisposition ); \ |             __catchResult.useActiveException( resultDisposition ); \ | ||||||
|         } \ |         } \ | ||||||
|         INTERNAL_CATCH_REACT( __catchResult ) \ |         INTERNAL_CATCH_REACT( __catchResult ) \ | ||||||
|     } while( Catch::alwaysFalse( sizeof(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look |     } 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 &&. | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ | #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ | ||||||
|   | |||||||
| @@ -119,8 +119,9 @@ namespace Catch { | |||||||
|     std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); |     std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); | ||||||
|  |  | ||||||
|     // This is just here to avoid compiler warnings with macro constants and boolean literals |     // This is just here to avoid compiler warnings with macro constants and boolean literals | ||||||
|     inline bool alwaysTrue( std::size_t = 0 ) { return true; } |     inline bool isTrue( bool value ){ return value; } | ||||||
|     inline bool alwaysFalse( std::size_t = 0 ) { return false; } |     inline bool alwaysTrue() { return true; } | ||||||
|  |     inline bool alwaysFalse() { return false; } | ||||||
|  |  | ||||||
|     void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); |     void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský