19.5 Determining Class Types

Ru-Brd

With all the classification templates described in the previous section, only class types ( class es, struct s, and union s) remain to be recognized. One approach is to use the SFINAE principle as demonstrated in Section 15.2.2 on page 266.

Another approach is to proceed by elimination : If a type is not a fundamental type, not an enumeration type, and not a compound type, it must be a class type. The following straightforward template implements this idea:

  // types/type8.hpp  template<typename T>  class IsClassT {    public:      enum { Yes = IsFundaT<T>::No &&                   IsEnumT<T>::No &&                   !CompoundT<T>::IsPtrT &&                   !CompoundT<T>::IsRefT &&                   !CompoundT<T>::IsArrayT &&                   !CompoundT<T>::IsPtrMemT &&                   !CompoundT<T>::IsFuncT };      enum { No = !Yes };  }; 
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