i********r 发帖数: 131 | 1 If the number of loops are only known at run time, the variadic template won
't work. The only way I can think of is recursion:
#include
#include
using namespace std;
void do_something(const vector& vars)
{
cout << "do_something with loop variables: ";
for (auto& i: vars)
cout << i << " ";
cout << endl;
}
// method 2:
void myLoop(const vector& inputs, vector& vars)
{
if (inputs.size() == vars.size()) {
... 阅读全帖 |
|