POD classification

Four structs classify types as to whether or not they have trivial special members as defined in section 12 of the C++ standard:

This library will answer correctly for non-class types. But user defined class types will always answer false to any of these queries. If you create a class with trivial special members, and you want that class to be able to take advantage of any optimizations that might arise from the assumption of trivial special members, you can specialize these structs:

Note that in the Example of specialized structs these specializations need not worry about cv qualifications. The higher level has_trival_XXX structs do that for you.

Finally there is an is_POD struct that will answer true if a type answers true on all four of the above queries.

Listing: Example of specialized structs
template <>
struct Metrowerks::details::class_has_trivial_default_ctor<MyClass>

   {static const bool value = true;};

template <>

struct Metrowerks::details::class_has_trivial_copy_ctor<MyClass>

   {static const bool value = true;};

 
template <>

struct Metrowerks::details::class_has_trivial_assignment<MyClass>

   {static const bool value = true;};

 
template <>

struct Metrowerks::details::class_has_trivial_dtor<MyClass>

   {static const bool value = true;};