Created
December 31, 2015 01:29
-
-
Save XeCycle/9c0604ed82edc4c04819 to your computer and use it in GitHub Desktop.
apply a tuple of parameters to a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace tuple_util_impl { | |
template <size_t... i, class Function, class Tuple> | |
auto spread_call(std::index_sequence<i...>, Function f, Tuple&& t) | |
-> decltype(f(std::get<i>(t)...)) | |
{ | |
return f(std::get<i>(t)...); | |
} | |
} // namespace tuple_util_impl | |
template <class Function, class Tuple> | |
auto spread_call(Function&& f, Tuple&& t) -> decltype( | |
tuple_util_impl::spread_call( | |
std::make_index_sequence<std::tuple_size<typename std::decay<Tuple>::type>::value>(), | |
f, t)) | |
{ | |
return tuple_util_impl::spread_call( | |
std::make_index_sequence<std::tuple_size<typename std::decay<Tuple>::type>::value>(), | |
std::forward<Function>(f), std::forward<Tuple>(t)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment