c++-gtk-utils
Static Public Attributes | List of all members
Cgu::DoIf::RelatedTest< Base, Obj > Class Template Reference

Class for compile time testing of inheritance relationships. More...

#include <c++-gtk-utils/do_if.h>

Static Public Attributes

static const bool value
 

Detailed Description

template<class Base, class Obj>
class Cgu::DoIf::RelatedTest< Base, Obj >

Class for compile time testing of inheritance relationships.

See also
DoIf::mem_fun DoIf::fun

This class provides a compile time test of whether the Obj class template parameter type is related to the Base class template parameter type by public derivation, or they are of the same type: the 'value' public member will be true if they are, otherwise false. Everything in it comprises a compile time constant so that 'value' can be used as a template parameter for conditional complation. Because 'RelatedTest' has a static member named 'value', it can also be used with boost's 'enable_if' templates.

This class tests convertibility, and constness is not discarded in making the test. Whilst a non-const type passed as the second template parameter will (if the other conditions referred to above are met) be shown as related to a const base type or const same type specified as the first template parameter type, the reverse is not true. This ensures that the DoIf::mem_fun() and DoIf::fun() conditional compilation functions work correctly.

Since 1.2.10

Member Data Documentation

◆ value

template<class Base , class Obj >
const bool Cgu::DoIf::RelatedTest< Base, Obj >::value
static
Initial value:
= sizeof(test(static_cast<Obj*>(0))) == sizeof(yes)
&& sizeof(test(static_cast<void*>(0))) == sizeof(no)

A compile time constant which indicates whether the Obj class template parameter type is related to the Base class template parameter type by public derivation, or they are of the same type. Because it is a compile time constant it can be used as a template parameter and therefore for conditional compilation.

This constant specifies convertibility, and constness is not discarded in making the test. Whilst a non-const type passed as the second template parameter will (if the other conditions referred to above are met) be shown as related to a const base type or const same type specified as the first template parameter type, the reverse is not true. This ensures that the DoIf::mem_fun() and DoIf::fun() conditional compilation functions work correctly.

Since 1.2.10


The documentation for this class was generated from the following file: