diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp index 21cc593a..f21c4eec 100644 --- a/include/internal/catch_expression_lhs.hpp +++ b/include/internal/catch_expression_lhs.hpp @@ -13,8 +13,6 @@ namespace Catch { -struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - // Wraps the LHS of an expression and captures the operator and RHS (if any) - wrapping them all // in an ExpressionResultBuilder object template @@ -76,6 +74,8 @@ public: template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& ); template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& ); template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& ); + template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); + template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); private: template diff --git a/include/internal/catch_expressionresult_builder.h b/include/internal/catch_expressionresult_builder.h index 5bf41379..13855888 100644 --- a/include/internal/catch_expressionresult_builder.h +++ b/include/internal/catch_expressionresult_builder.h @@ -16,6 +16,8 @@ namespace Catch { +struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; + // Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as // the result of evaluating it. This is used to build an AssertionResult object class ExpressionResultBuilder { @@ -43,6 +45,9 @@ public: AssertionResult buildResult( AssertionInfo const& info ) const; + template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); + template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); + private: AssertionResultData m_data; struct ExprComponents { diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index ec07f1fc..97386709 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -33,9 +33,7 @@ TEST_CASE { std::pair aNicePair( 1, 2 ); - // !TBD: would be nice if this could compile without the extra parentheses - REQUIRE( (std::pair( 1, 2 )) == aNicePair ); - + REQUIRE( (std::pair( 1, 2 )) == aNicePair ); } /////////////////////////////////////////////////////////////////////////////// @@ -45,13 +43,8 @@ TEST_CASE "Where the is more to the expression after the RHS" ) { - /* - int a = 1; - int b = 2; - - // This only captures part of the expression, but issues a warning about the rest - REQUIRE( a == 2 || b == 2 ); - */ +// int a = 1, b = 2; +// REQUIRE( a == 2 || b == 2 ); WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" ); } ///////////////////////////////////////////////////////////////////////////////