Closed snirgaz closed 7 years ago
Interesting. product<4>(A);
seems easy enough though lacking, I'm not sure about product(A, 4);
for product<4>(A)
this seems to do the job. but a runtime argument would be better... trying to write that without having to do a new product class:
namespace iter {
namespace impl {
template <std::size_t... Is, typename Container>
decltype(auto) product_repeat_impl(
std::index_sequence<Is...>, Container&& container) {
return product(((void)Is, Container(container))...);
}
}
template <std::size_t N, typename Container>
decltype(auto) product(Container&& container) {
return impl::product_repeat_impl(
std::make_index_sequence<N>{}, std::forward<Container>(container));
}
}
For my needs, I am fine with a compile time version. Are you planning to incorporate this is the code? Thanks!
done. I guess there's nothing stopping me from adding a version with an integral argument later
Would it be possible to add support for "repeat" in the product function similar to python? (https://docs.python.org/2/library/itertools.html#itertools.product) e.g -- product<4>(A,(4?)) would iterate over the cartesian product of 4 copies of A.
Thanks!