aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2016-05-27 22:05:52 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-05-27 22:05:52 +0000
commit34ed8bd836969908fb609498a425dc9e73155c75 (patch)
treeb8f1b13cd1078574c6d1e21b43635dfc6c5fc3d4
parent335a8a169ca8fd404064aaa4d8a5e4d30fe500bf (diff)
parent62fa5823cce4c13f024d9412df9aed61d5733a22 (diff)
downloadgtest-34ed8bd836969908fb609498a425dc9e73155c75.tar.gz
Merge "gtest: Add support for std::unique_ptr bool conversion" am: 0e40459835
am: 62fa5823cc * commit '62fa5823cce4c13f024d9412df9aed61d5733a22': gtest: Add support for std::unique_ptr bool conversion Change-Id: I92eaa762e9d37a6538830aa1239553ae6689287c
-rw-r--r--include/gtest/gtest.h15
-rw-r--r--include/gtest/internal/gtest-internal.h2
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