Chapter 19. Type Classification

Ru-Brd

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.

Ru-Brd


C++ Templates
C++ Templates: The Complete Guide
ISBN: 0201734842
EAN: 2147483647
Year: 2002
Pages: 185

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net