|
C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Rewrite boost::polymorphic_downcast.
More...
Files | |
| file | c++20/exercise-2-2.hpp |
| Solution to Exercise 2-2 (C++20). | |
| file | exercise-2-2.hpp |
| Solution to Exercise 2-2. | |
Namespaces | |
| namespace | exercise_2_2 |
| Encapsulate solution for Exercise 2-2. | |
| namespace | exercise_2_2::cpp20 |
| Encapsulate solution for Exercise 2-2 (C++20). | |
Functions | |
| static void | anonymous_namespace{chapter-2.cpp}::test_exercise_2_2 () |
| Tests for Exercise 2-2. | |
Rewrite boost::polymorphic_downcast.
2-2. The boost::polymorphic_downcast function template implements a checked
version of static_cast intended for downcasting pointers to polymorphic
objects:
In released software, the assertion disappears and polymorphic_downcast
can be as efficient as a simple static_cast. Use the type traits
facilities to write an implementation of the template that allows both
pointer and reference arguments.
|
static |
Tests for Exercise 2-2.
Definition at line 142 of file chapter-2.cpp.