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

Function DownCast_

tests/gtest/gtest.h:1353–1370  ·  view source on GitHub ↗

use like this: DownCast_ (foo);

Source from the content-addressed store, hash-verified

1351// namespace alone is not enough because the function can be found by ADL.
1352template<typename To, typename From> // use like this: DownCast_<T*>(foo);
1353inline To DownCast_(From* f) { // so we only accept pointers
1354 // Ensures that To is a sub-type of From *. This test is here only
1355 // for compile-time type checking, and has no overhead in an
1356 // optimized build at run-time, as it will be optimized away
1357 // completely.
1358 GTEST_INTENTIONAL_CONST_COND_PUSH_()
1359 if (false) {
1360 GTEST_INTENTIONAL_CONST_COND_POP_()
1361 const To to = nullptr;
1362 ::testing::internal::ImplicitCast_<From*>(to);
1363 }
1364
1365#if GTEST_HAS_RTTI
1366 // RTTI: debug mode only!
1367 GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);
1368#endif
1369 return static_cast<To>(f);
1370}
1371
1372// Downcasts the pointer of type Base to Derived.
1373// Derived must be a subclass of Base. The parameter MUST

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected