mirror of
https://github.com/google/googletest.git
synced 2025-01-14 00:20:57 +08:00
Resolve an issue where the resolution of operator<<
overloads would attempt to instantiate the incomplete testing::internal::Secret
type.
PiperOrigin-RevId: 543799815 Change-Id: Ic0a4f48d825bef26cb8cc74d8a0117b3a5ef3f14
This commit is contained in:
parent
8e32de89cf
commit
f269e15c5c
@ -925,9 +925,11 @@ using std::tuple_size;
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// A secret type that Google Test users don't know about. It has no
|
// 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.
|
// 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
|
// A helper for suppressing warnings on constant condition. It just
|
||||||
// returns 'condition'.
|
// returns 'condition'.
|
||||||
|
@ -67,11 +67,27 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest-spi.h"
|
#include "gtest/gtest-spi.h"
|
||||||
#include "src/gtest-internal-inl.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<std::is_constructible<T>::value, int>> = 0>
|
||||||
|
operator T() const; // NOLINT(google-explicit-constructor)
|
||||||
|
};
|
||||||
|
void operator<<(ConvertibleGlobalType&, int);
|
||||||
|
static_assert(sizeof(decltype(std::declval<ConvertibleGlobalType&>()
|
||||||
|
<< 1)(*)()) > 0,
|
||||||
|
"error in operator<< overload resolution");
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user