Primary Type Categories






Primary Type Categories

Each of these class templates defines a type predicate. The templates remove any top-level const or volatile qualifiers from their type argument Ty and then determine whether the resulting type belongs to the template's type category. These type categories are defined in the C++ Standard in Section 3.9 [basic.types]. The categories are complete and mutually exclusive: for any type Ty, exactly one of these type predicates will be true.

template < class Ty > struct is_void;

The template specialization is_void<Ty> is derived from TRue_type if the type Ty is a cv-qualified form of void. Otherwise, it is derived from false_type.

template < class Ty > struct is_integral;

The template specialization is_integral<Ty> is derived from TRue_type if the type Ty is a cv-qualified form of an integral type. Otherwise, it is derived from false_type.

An integral type is one of char, unsigned char, signed char, short, unsigned short, int, unsigned int, long, and unsigned long. If a compiler supports them, the C99 types long long and unsigned long long are also integral types.

template < class Ty > struct is_floating_point;

The template specialization is_floating_point<Ty> is derived from TRue_type if the type Ty is a cv-qualified form of a floating-point type. Otherwise, it is derived from false_type.

A floating-point type is one of float, double, and long double.

template < class Ty > struct is_array;

The template specialization is_array<Ty> is derived from true_type if the type Ty is a cv-qualified form of an array type. Otherwise, it is derived from false_type.

The class template array (see Chapter 4) is not an array type.

template < class Ty > struct is_pointer;

The template specialization is_pointer<Ty> is derived from true_type if the type Ty is a cv-qualified form of a pointer type. Otherwise, it is derived from false_type.

This predicate is true for ordinary pointer types but not for pointers to members.

template < class Ty > struct is_reference;

The template specialization is_reference<Ty> is derived from true_-type if the type Ty is a cv-qualified form of a reference type. Otherwise, it is derived from false_type.

template < class Ty > struct is_member_object_pointer;

The template specialization is_member_object_pointer<Ty> is derived from TRue_type if the type Ty is a cv-qualified form of pointer to data member. Otherwise, it is derived from false_type.

template < class Ty > struct is_member_function_pointer;

The template specialization is_member_function_pointer<Ty> is derived from true_type if the type Ty is a cv-qualified form of pointer to member function. Otherwise, it is derived from false_type.

template < class Ty > struct is_enum;

The template specialization is_enum<Ty> is derived from true_type if the type Ty is a cv-qualified form of an enumeration type. Otherwise, it is derived from false_type.

template < class Ty > struct is_union;

The template specialization is_union<Ty> is derived from true_type if the type Ty is a cv-qualified form of a union type. Otherwise, it is derived from false_type.

An implementation may define this template as template <class Ty> struct is_union {}.

This template's compromise rule means that code that uses is_union to determine whether a type is a union typeby looking for one of the base types true_type or false_typewill produce a diagnostic if is_union is not supported.

template < class Ty > struct is_class;

The template specialization is_class<Ty> is derived from true_type if the type Ty is a cv-qualified form of a class type but not a union type. Otherwise, it is derived from false_type.

An implementation may define this template as template <class Ty> struct is_class {}.

This template's compromise rule means that code that uses is_class to determine whether a type is a class typeby looking for one of the base types true_type or false_typewill produce a diagnostic if is_class is not supported.

template < class Ty > struct is_function;

The template specialization is_function<Ty> is derived from true_type if the type Ty is a cv-qualified form of a function type. Otherwise, it is derived from false_type.

Note that this predicate detects function types, not pointers to functions. As we saw in Chapter 9, a function type is a return type followed by a left parenthesis followed by a possibly empty argument list followed by a right parenthesis.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows