I have the following code:
template <typename L>
double measure( L&& action )
{
using namespace std::chrono;
high_resolution_clock::time_point start, end;
duration<double> timeSpan;
start = high_resolution_clock::now();
action();
end = high_resolution_clock::now();
timeSpan = duration_cast<milliseconds>(end - start);
return timeSpan.count();
}
and I use it like this:
cout << measure([](){ mergeSort<float>(array, 0, 10000); }) << endl << endl;
And so far, this is the only way I know to pass lambda functions. BUT, I was trying to make this function more complete, allowing to pass a ratio<> as template argument, to specify the ratio<> of the timeSpan template, to return time in other measure than milliseconds...
So, I want to know how can I pass multiple template arguments to a function and pass a lambda together. What should I specify on the template as the lambda's type or, what else can I do to achieve something like this:
timer::measure<ratio<1,1000>>([](){ mergeSort<float>(array, 0, 10000); })
?