Chapter 19. Type Classification
It is sometimes useful to be able to know whether a template parameter is a built-in type, a pointer type, or a class type, and so forth. In the following sections we develop a general-purpose type template that allows us to determine various properties of a given type. As a result we will be able to write code like the following:
if (TypeT<T>::IsPtrT) { … } else if (TypeT<T>::IsClassT) { … }
Furthermore, expressions such as TypeT<T>::IsPtrT
will be Boolean constants that are valid nontype template arguments. In turn, this allows the construction of more sophisticated and more powerful templates that specialize their behavior on the properties of their type arguments.
19.1 Determining Fundamental Types ...
Get C++ Templates: The Complete Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.