Template Metafunction If

Conditional metafunction returning the first typename if true, the second if false. A second conditional (if_c) metafunction returns the first constant if true, the second if false;

namespace framework {
namespace meta
{
template struct if_;
template struct if_ { typedef T0 value; };
template struct if_ { typedef T1 value; };
template struct if_c;
template struct if_c { static T value; };
template struct if_c { static T value; };
template T if_c::value = C0;
template T if_c::value = C1;
} // namespace meta
} // namespace framework

For an example, see TemplateMetafunctionHasFunction.


TemplateMetaprogrammingTechniques TemplateMetafunctionIdentity TemplateMetafunctionHasFunction CategoryCppTemplates