diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 8b66714598..52215409ac 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -925,9 +925,11 @@ using std::tuple_size; namespace internal { // A secret type that Google Test users don't know about. It has no -// definition on purpose. Therefore it's impossible to create a +// accessible constructors on purpose. Therefore it's impossible to create a // Secret object, which is what we want. -class Secret; +class Secret { + Secret(const Secret&) = delete; +}; // A helper for suppressing warnings on constant condition. It just // returns 'condition'. diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index dd049a00d5..6caa03fd34 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -67,11 +67,27 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { #include #include #include +#include #include #include "gtest/gtest-spi.h" #include "src/gtest-internal-inl.h" +struct ConvertibleGlobalType { + // The inner enable_if is to ensure invoking is_constructible doesn't fail. + // The outer enable_if is to ensure the overload resolution doesn't encounter + // an ambiguity. + template < + class T, + std::enable_if_t< + false, std::enable_if_t::value, int>> = 0> + operator T() const; // NOLINT(google-explicit-constructor) +}; +void operator<<(ConvertibleGlobalType&, int); +static_assert(sizeof(decltype(std::declval() + << 1)(*)()) > 0, + "error in operator<< overload resolution"); + namespace testing { namespace internal {