summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal
diff options
context:
space:
mode:
authorIgor Nazarenko <igor.n.nazarenko@gmail.com>2020-05-05 18:06:33 (GMT)
committerIgor Nazarenko <igor.n.nazarenko@gmail.com>2020-05-05 18:06:33 (GMT)
commit4c9ad191e14e5926ce0213d7dddb7a35529c2756 (patch)
tree0fa61001ec696666cf9b0ff363a859cbff8a28f8 /googletest/include/gtest/internal
parent0eea2e9fc63461761dea5f2f517bd6af2ca024fa (diff)
downloadgoogletest-4c9ad191e14e5926ce0213d7dddb7a35529c2756.zip
googletest-4c9ad191e14e5926ce0213d7dddb7a35529c2756.tar.gz
googletest-4c9ad191e14e5926ce0213d7dddb7a35529c2756.tar.bz2
Detect proto messages based on presense of DebugString.
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index fabc804..6da1d91 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -880,11 +880,34 @@ class GTEST_API_ Random {
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
typename std::remove_const<typename std::remove_reference<T>::type>::type
-// IsAProtocolMessage<T>::value is a compile-time bool constant that's
-// true if and only if T is type proto2::MessageLite or a subclass of it.
+// IsAProtocolMessage<T>::value is a compile-time bool constant that's true if
+// and only if T has methods DebugString() and ShortDebugString() that return
+// std::string.
template <typename T>
-struct IsAProtocolMessage
- : public std::is_convertible<const T*, const ::proto2::MessageLite*> {};
+class IsAProtocolMessage {
+ private:
+ template <typename C>
+ static constexpr auto CheckDebugString(C*) ->
+ typename std::is_same<std::string,
+ decltype(std::declval<const C>().DebugString())>::type;
+ template <typename>
+ static constexpr std::false_type CheckDebugString(...);
+
+ template <typename C>
+ static constexpr auto CheckShortDebugString(C*) -> typename std::is_same<
+ std::string, decltype(std::declval<const C>().ShortDebugString())>::type;
+ template <typename>
+ static constexpr std::false_type CheckShortDebugString(...);
+
+ using HasDebugStringType = decltype(CheckDebugString<T>(nullptr));
+ using HasShortDebugStringType = decltype(CheckShortDebugString<T>(nullptr));
+
+ public:
+ static constexpr bool value =
+ HasDebugStringType::value && HasShortDebugStringType::value;
+};
+
+template <typename T> constexpr bool IsAProtocolMessage<T>::value;
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// STL-style container class, the first overload of IsContainerTest