35 lines
834 B
C++
35 lines
834 B
C++
#ifndef TIMERHELPERS_H
|
|
#define TIMERHELPERS_H
|
|
|
|
#include <functional>
|
|
|
|
|
|
namespace Timer {
|
|
namespace Helpers {
|
|
|
|
template <int... Is>
|
|
struct index {};
|
|
|
|
template <int N, int... Is>
|
|
struct gen_seq : gen_seq<N - 1, N - 1, Is...> {};
|
|
|
|
template <int... Is>
|
|
struct gen_seq<0, Is...> : index<Is...> {};
|
|
|
|
template <typename ...FunctionArguments, typename ...Arguments, int... Is>
|
|
void execute(std::function<void(FunctionArguments...)> const & function, std::tuple<Arguments...>& tuple, index<Is...>)
|
|
{
|
|
function(std::get<Is>(tuple)...);
|
|
}
|
|
|
|
template <typename ...FunctionArguments, typename ...Arguments>
|
|
void execute(std::function<void(FunctionArguments...)> const & function, std::tuple<Arguments...>& tuple)
|
|
{
|
|
execute(function, tuple, gen_seq<sizeof...(Arguments)>{});
|
|
}
|
|
|
|
} // namespace Helpers
|
|
} // namespace Timer
|
|
|
|
#endif // TIMERHELPERS_H
|