diff options
-rw-r--r-- | include/gtest/gtest.h | 15 | ||||
-rw-r--r-- | include/gtest/internal/gtest-internal.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h index 6fa0a39..8f310a6 100644 --- a/include/gtest/gtest.h +++ b/include/gtest/gtest.h @@ -258,8 +258,21 @@ class GTEST_API_ AssertionResult { // Copy constructor. // Used in EXPECT_TRUE/FALSE(assertion_result). AssertionResult(const AssertionResult& other); + // Used in the EXPECT_TRUE/FALSE(bool_expression). - explicit AssertionResult(bool success) : success_(success) {} + // + // T must be contextually convertible to bool. + // + // The second parameter prevents this overload from being considered if + // the argument is implicitly convertible to AssertionResult. In that case + // we want AssertionResult's copy constructor to be used. + template <typename T> + explicit AssertionResult( + const T& success, + typename internal::EnableIf< + !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type* + /*enabler*/ = NULL) + : success_(success) {} // Returns true iff the assertion succeeded. operator bool() const { return success_; } // NOLINT diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h index 0dcc3a3..f58f65f 100644 --- a/include/gtest/internal/gtest-internal.h +++ b/include/gtest/internal/gtest-internal.h @@ -784,7 +784,7 @@ class ImplicitlyConvertible { // MakeFrom() is an expression whose type is From. We cannot simply // use From(), as the type From may not have a public default // constructor. - static From MakeFrom(); + static typename AddReference<From>::type MakeFrom(); // These two functions are overloaded. Given an expression // Helper(x), the compiler will pick the first version if x can be |