Fix Timer Variadic Template Implementation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef UTIL_HELPERS_H
|
||||
#define UTIL_HELPERS_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
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 Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_HELPERS_H
|
||||
Reference in New Issue
Block a user