Menu

if_contains_select_type.h File Reference

#include "config/type_traits/if_select_type.h"
#include "config/type_traits/contains_type.h"

Go to the source code of this file.

Defines

#define IF_CONTAINS_SELECT_TYPE_(NAME)
 This macro generates a compile time testing class which selects a primary type if it is defined within a type/class. If it is not defined there, a secondary class is selected.

Define Documentation

#define IF_CONTAINS_SELECT_TYPE_ ( NAME   ) 

This macro generates a compile time testing class which selects a primary type if it is defined within a type/class. If it is not defined there, a secondary class is selected.

Parameters:
[in] NAME Type we are looking for inside a type/class.
Usage:
The macro defines a template class with two type parameters. The first (T) is the type which may contain a definition of type NAME. If it contains a definition, the type member is defined as T::NAME. Otherwise it's the second type parameter (Alternative).
Example:
struct TypeWithTestType {
    typedef int TestType;
};
struct TypeWithoutTestType {
};

IF_CONTAINS_SELECT_TYPE_(TestType);

if_contains_select_type_TestType<TypeWithoutTestType, short>::type a; // type of a is short
if_contains_select_type_TestType<TypeWithTestType, short>::type b;    // type of b is TypeWithTestType::TestType