19#ifndef UTILS_CARTESIAN_PRODUCT_HPP
20#define UTILS_CARTESIAN_PRODUCT_HPP
28template <
class Body,
class...>
struct cart_prod_impl {
29 template <
class... Is>
void operator()(
const Body &op, Is... is)
const {
33 void operator()(
const Body &)
const { ; }
36template <
class Body,
class Head,
class... Tail>
37struct cart_prod_impl<Body, Head, Tail...> {
38 template <
class... Is>
39 void operator()(
const Head &head,
const Tail... tail, Is... is)
const {
40 for (
auto it = std::begin(head); it != std::end(head); ++it) {
41 detail::cart_prod_impl<Body, Tail...>{}(tail..., is..., it);
53template <
typename Body,
typename... ForwardRange>
55 detail::cart_prod_impl<Body, ForwardRange...>{}(rng..., op);
void cartesian_product(const Body &op, const ForwardRange &...rng)
Call op with each element of the cartesian product set of rng.