November 2002
Intermediate to advanced
552 pages
10h 52m
English
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.
Read now
Unlock full access