/* * Copyright (C) 2014 Cloudius Systems, Ltd. */ #ifndef APPLY_HH_ #define APPLY_HH_ #include template struct index_list { }; template struct index_list_helper; template struct index_list_helper> { using type = index_list; }; template struct index_list_helper> { using type = typename index_list_helper>::type; }; template using make_index_list = typename index_list_helper<0, N, index_list<>>::type; template struct apply_helper; template struct apply_helper, index_list> { static auto apply(Func func, std::tuple args) { return func(std::get(std::move(args))...); } }; template auto apply(Func func, std::tuple&& args) { using helper = apply_helper, make_index_list>; return helper::apply(std::move(func), std::move(args)); } #endif /* APPLY_HH_ */