

C++ Cartesian Products - 16s
https://github.com/16s/cartesian_product

======
_delirium
The approach of hardcoding a set of nested loops per each possible count of
input sets is probably okay for most common use-cases, but wouldn't a more
general algorithm be better? You'd either need to generate N nested loops via
template metaprogramming, or else use an algorithm that didn't explicitly have
the nested loops.

~~~
16s
I've thought of doing something more general (see my while loops), and I've
looked for other bits of source code that use a general approach, but haven't
found any in C++. Maybe I've just over-looked it

You're right, most people hard code the for loops they need. I call that the
"intuitive approach". It works and it makes sense I think and performs OK. In
fact, whenever I come up with new ways to do CPs I always compare their
performance to the hard coded loops.

------
16s
OP here.

I've been fascinated by CPs for some time. In particular, efficient ways in
which to generate them. So I placed my source code on github that demonstrates
a few ways I've done it in the past. My hope is that others can offer
suggestions and insight into different (especially faster) approaches to
generate them.

