2 ms·
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 a
by _delirium 16y ago
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 16y agoI'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.