tuple: add a map function over a tuple
This commit is contained in:
parent
741012151b
commit
f4465329c8
24
tuple.hpp
24
tuple.hpp
@ -22,6 +22,7 @@
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace util::tuple {
|
||||
@ -165,6 +166,29 @@ namespace util::tuple {
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace detail {
|
||||
template <typename FuncT, typename ArgT, std::size_t ...Indices>
|
||||
auto
|
||||
convert (std::index_sequence<Indices...>, FuncT &&func, ArgT &&arg)
|
||||
{
|
||||
return std::tuple (std::invoke (func, std::get<Indices> (arg))...);
|
||||
}
|
||||
};
|
||||
|
||||
template <
|
||||
typename FuncT,
|
||||
typename ArgT,
|
||||
typename IndicesV = std::make_index_sequence<
|
||||
std::tuple_size_v<std::decay_t<ArgT>>
|
||||
>
|
||||
>
|
||||
auto convert (FuncT &&func, ArgT &&arg)
|
||||
{
|
||||
return detail::convert (IndicesV{}, func, arg);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// do nothing with a set of parameters.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user