MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / DefaultPrintNonContainerTo

Function DefaultPrintNonContainerTo

tests/gtest/gtest.h:8244–8272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8242// user doesn't define PrintTo() for it.
8243template <typename T>
8244void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
8245 // With the following statement, during unqualified name lookup,
8246 // testing::internal2::operator<< appears as if it was declared in
8247 // the nearest enclosing namespace that contains both
8248 // ::testing_internal and ::testing::internal2, i.e. the global
8249 // namespace. For more details, refer to the C++ Standard section
8250 // 7.3.4-1 [namespace.udir]. This allows us to fall back onto
8251 // testing::internal2::operator<< in case T doesn't come with a <<
8252 // operator.
8253 //
8254 // We cannot write 'using ::testing::internal2::operator<<;', which
8255 // gcc 3.3 fails to compile due to a compiler bug.
8256 using namespace ::testing::internal2; // NOLINT
8257
8258 // Assuming T is defined in namespace foo, in the next statement,
8259 // the compiler will consider all of:
8260 //
8261 // 1. foo::operator<< (thanks to Koenig look-up),
8262 // 2. ::operator<< (as the current namespace is enclosed in ::),
8263 // 3. testing::internal2::operator<< (thanks to the using statement above).
8264 //
8265 // The operator<< whose type matches T best will be picked.
8266 //
8267 // We deliberately allow #2 to be a candidate, as sometimes it's
8268 // impossible to define #1 (e.g. when foo is ::std, defining
8269 // anything in it is undefined behavior unless you are a compiler
8270 // vendor.).
8271 *os << value;
8272}
8273
8274} // namespace testing_internal
8275

Callers 1

DefaultPrintToFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected