Library of Assembled Shared Sources
lass::meta::If< Condition, TrueType, FalseType > Struct Template Reference

Evaluates meta expression TrueType or FalseType based on a meta condition Condition. More...

#include <if.h>

Detailed Description

template<typename Condition, typename TrueType, typename FalseType>
struct lass::meta::If< Condition, TrueType, FalseType >

Evaluates meta expression TrueType or FalseType based on a meta condition Condition.

Depending on whether Condition is meta::True or meta::False, meta::If derives from TrueType or FalseType, thereby selecting the meta code path.

meta::If can roughly be expressed as meta::Select if only the resulting Type is needed.

Evaluates meta expression TrueType or FalseType based on a meta condition Condition.
Definition if.h:84
Select a type based on a meta condition that evaluates to meta::True or meta::False.
Definition meta/select.h:70

Apart from being the shorter expression, using meta::If has the following benefits:

  • meta::It is faster. Using meta::Select requires the compiler to both evaluate A::Type and B::Type, regardless fo the outcome. meta::If postpones the evaluation by deriving from the result.
  • meta::Select only has the Type field as result. If other fields are needed, you should use meta::If as it derives directly from A or B. Any field that is available in A or B is thus also available in the result.

meta::If however cannot be used with fundamental types as you need to be able to derive from the result. This is not really a short coming, as meta::If is designed to select meta code paths, and not to select a type. Use meta::Select instead.

Definition at line 83 of file if.h.


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