Defines a member, value, to be one of the basicClassTypes values. More...
#include <classTraits.h>
Public Types | |
enum | { value } |
typedef removeCV< T >::type | MutableType |
typedef removeReference < MutableType >::type | RawType |
Defines a member, value, to be one of the basicClassTypes values.
This class exists so that you can use the defined value to select implementation of a function or class based on the basicType of the template parameter, T.
For example, suppose you want to write a template function that can handle any parameter type -- but that you know that different data types must have different algorithms. Here's how you can use the basicClassType template to your advantage:
template<int N, class T> struct alternative_implementations; // // alternative_implementations // is a library of implementations of your algorithm based on the // type of the template parameter to your function, shown below. template<class T> void function(T &t) // // Your function just becomes a wrapper around the template trickery // that selects the desired implementation based on the type of the // parameter. // { alternative_implementations< basicClassType<T>::value, T >::doit(t); // Note: if the above line of code fails to compile it is likely // because there is no specialization for this kind of T! } Here is an example specialization: template<class T> struct alternative_implementations<bctIntegralType, T> { static void doit(T &t) { ... }; };
Definition at line 1174 of file classTraits.h.
typedef removeCV<T>::type MutableType |
Definition at line 1219 of file classTraits.h.
typedef removeReference<MutableType>::type RawType |
Definition at line 1220 of file classTraits.h.
anonymous enum |
Definition at line 1222 of file classTraits.h.