diff options
author | Luis Hector Chavez <lhchavez@google.com> | 2016-05-27 22:03:29 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-05-27 22:03:29 +0000 |
commit | 62fa5823cce4c13f024d9412df9aed61d5733a22 (patch) | |
tree | a67eae2fbdc88e17651174774da21a50231eeae7 | |
parent | 529764ba68dd5573e636e21e812ca1e4774df6b6 (diff) | |
parent | 0e40459835dbefebda48820b9eb7cc9b16855274 (diff) | |
download | gtest-62fa5823cce4c13f024d9412df9aed61d5733a22.tar.gz |
Merge "gtest: Add support for std::unique_ptr bool conversion"
am: 0e40459835
* commit '0e40459835dbefebda48820b9eb7cc9b16855274':
gtest: Add support for std::unique_ptr bool conversion
Change-Id: I82117e03eeeba3b163b2487255e05e8d0b8b5eed
-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 |