combine¶
Header¶
#include <fit/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 <fit.hpp>
#include <cassert>
#include <tuple>
#include <utility>
int main() {
auto f = fit::combine(
fit::construct<std::tuple>(),
fit::capture(1)(fit::construct<std::pair>()),
fit::capture(2)(fit::construct<std::pair>()));
assert(f(3, 7) == std::make_tuple(std::make_pair(1, 3), std::make_pair(2, 7)));
}