basicClassType< T > Struct Template Reference

Defines a member, value, to be one of the basicClassTypes values. More...

#include <classTraits.h>

List of all members.

Public Types

enum  { value }
typedef removeCV< T >::type MutableType
typedef removeReference
< MutableType >::type 
RawType

Detailed Description

template<class T>
struct cxxtls::basicClassType< T >

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.


Member Typedef Documentation

typedef removeCV<T>::type MutableType

Definition at line 1219 of file classTraits.h.

Definition at line 1220 of file classTraits.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
value 

Definition at line 1222 of file classTraits.h.


The documentation for this struct was generated from the following file:
Generated on Wed Feb 29 22:52:34 2012 for CXXUtilities by  doxygen 1.6.3