|
C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Print data-types using Boost MPL. More...
Files | |
| file | exercise-2-3.hpp |
| Solution to Exercise 2-3. | |
Namespaces | |
| namespace | exercise_2_3 |
| Encapsulate solution for Exercise 2-3. | |
Functions | |
| static void | anonymous_namespace{chapter-2.cpp}::test_exercise_2_3 () |
| Tests for Exercise 2-3. | |
Print data-types using Boost MPL.
2-3. Use the type traits facilities to implement a type_descriptor class
template, whose instances, when streamed, print the type of their
template parameters:
// prints "int"
std::cout << type_descriptor<int>();
// prints "char*"
std::cout << type_descriptor<char*>();
// prints "long const*&"
std::cout << type_descriptor<long const*&>();
You can assume that type_descriptor’s template parameter is limited to
compound types built from the following four integral types: char,
short int, int, and long int.
|
static |
Tests for Exercise 2-3.
Definition at line 160 of file chapter-2.cpp.