enable_if(3) enable_if(3)

NAME

enable_if - function application predicate

SYNOPSIS

#include <cfl/functions/enable_if.hpp>

template <typename...> struct P;

auto g = enable_if <P> (f);

static_assert ((P <F, U...>::value), "");

f (u...) == g (u...) 

DESCRIPTION

Auguments a function f of type F with a predicate P for conditional application. When g is invoked with arguments u of type U, f is only eligible for application when P <F, U...> is true.

Note how the function type F itself is an argument to the predicate. In the general case, the predicate may require this to for instance check the return type of the function f (u...).

RETURN VALUES

Another function, only applicable when function and argument types fulfill the predicate.

STANDARDS

enable_if is a container function.

NOTES

Following the CFL naming conventions strictly, enable_if should really be called fenable_if, as the predicate argument is a factory. The proper name is not very pleasing to the eye though, and until constexpr lambda is more widely implemented, this inconcistency is accepted in CFL.