C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Encapsulate solution for Exercise 2-2 (C++20). More...
Functions | |
template<typename Target , typename Source > | |
Target | polymorphic_downcast (Source *const x) |
Check the validity of a downcast. | |
template<typename Target , typename Source > | |
Target | polymorphic_downcast (Source &x) |
Check the validity of a downcast. | |
Encapsulate solution for Exercise 2-2 (C++20).
|
inline |
Check the validity of a downcast.
This method asserts (in debug builds only) that the downcast was legal. This overload accepts a reference type.
Target | The resulting type of the cast. |
Source | The input datatype (wihtout reference). Do not specify this explicitly: it should be deduced by the compiler. |
[in] | x | An input reference type. |
Definition at line 57 of file c++20/exercise-2-2.hpp.
|
inline |
Check the validity of a downcast.
This method asserts (in debug builds only) that the downcast was legal. This overload accepts a pointer type.
Target | The resulting type of the cast. |
Source | The input datatype (wihtout pointer). Do not specify this explicitly: it should be deduced by the compiler. |
[in] | x | An input pointer type. |
Definition at line 37 of file c++20/exercise-2-2.hpp.