combine¶
Header¶
#include <boost/hof/combine.hpp>
Description¶
The combine
function adaptor combines several functions together with
their arguments. It essentially zips each function with an argument before
calling the main function.
Synopsis¶
template<class F, class... Gs>
constexpr combine_adaptor<F, Gs...> combine(F f, Gs... gs);
Semantics¶
assert(combine(f, gs...)(xs...) == f(gs(xs)...));
Example¶
#include <boost/hof.hpp>
#include <cassert>
#include <tuple>
#include <utility>
int main() {
auto f = boost::hof::combine(
boost::hof::construct<std::tuple>(),
boost::hof::capture(1)(boost::hof::construct<std::pair>()),
boost::hof::capture(2)(boost::hof::construct<std::pair>()));
assert(f(3, 7) == std::make_tuple(std::make_pair(1, 3), std::make_pair(2, 7)));
}