C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Encapsulate solution for Exercise 2-4 (C++20). More...
Classes | |
struct | type_descriptor |
Print (a limited set of) data-types. More... | |
Functions | |
template<typename T > | |
consteval T * | error_unhandled_type () |
Produce a compile-time failure for an "unhandled" type. | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, type_descriptor< T > const &) |
Encapsulate solution for Exercise 2-4 (C++20).
consteval T * exercise_2_4::cpp20::error_unhandled_type | ( | ) |
Produce a compile-time failure for an "unhandled" type.
The purpose of this is to induce a compilation error that indicates the type (T
) that was not handled in the constexpr-if
cases for operator<<
.
T | The type that was "unhandled." |
nullptr
. Definition at line 51 of file c++20/exercise-2-4.hpp.
std::ostream & exercise_2_4::cpp20::operator<< | ( | std::ostream & | os, |
type_descriptor< T > const & | |||
) |
Definition at line 54 of file c++20/exercise-2-4.hpp.