use like this: DownCast_ (foo);
| 1351 | // namespace alone is not enough because the function can be found by ADL. |
| 1352 | template<typename To, typename From> // use like this: DownCast_<T*>(foo); |
| 1353 | inline 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 |
nothing calls this directly
no outgoing calls
no test coverage detected