Template Struct enable_if

Inheritance Relationships

Base Type

Struct Documentation

template<class Condition, class T = void>
struct enable_if : public ecl::enable_if_c<Condition::value, void>

Enables the SFINAE concept.

This is the same as the boost and future C++0x implementations. Use this to do things like helping to instantiate families of specialisations. For example:

#include <ecl/type_traits/fundamental_types.hpp> // for is_float

// This will instantiate if it is anything except float or double.
template <typename T, typename Enable = void>
class TestObject {
public:
    bool isFloatSpecialisation() { return false; }
};

// This specialisation will instantiate it T is float or double.
template <typename T>
class TestObject< T, typename enable_if< is_float<T> >::type > {
public:
    bool isFloatSpecialisation() { return true; }
};