Functions that accept other functions as an input parameter or functions that return other functions are called higher-order functions. For example, the following functions are higher order:
typedef void(*function_t)(int);
function_t higher_order_function1();
void higher_order_function2(function_t f);
function_t higher_order_function3(function_t f); f);
We already saw higher-order metafunctions in the recipes Using type vector of types and Manipulating vector of types recipes from this chapter, where we used boost::mpl::transform.
In this recipe, we'll try to make our own higher-order metafunction named coalesce, which accepts two types and two metafunctions. The coalesce metafunction applies the first type-parameter to the first metafunction and compares the resulting type with the boost::mpl::false_ type. If the resulting type is the boost...