diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-05-27 21:54:19 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-05-27 21:54:19 +0000 |
commit | 0e40459835dbefebda48820b9eb7cc9b16855274 (patch) | |
tree | a67eae2fbdc88e17651174774da21a50231eeae7 | |
parent | 55cc0e85b97b656885aaab8d5688ff9b32bc7e88 (diff) | |
parent | 1d8db72ddabfe39e43b6b25a00023d22748d2044 (diff) | |
download | gtest-0e40459835dbefebda48820b9eb7cc9b16855274.tar.gz |
Merge "gtest: Add support for std::unique_ptr bool conversion"
-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 |