Support fmap over a tuple
This commit is contained in:
parent
48a85dfd66
commit
e4fcf82f70
1 changed files with 11 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <psemek/util/range.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
|
@ -25,6 +26,16 @@ namespace psemek::util
|
|||
else
|
||||
return std::optional<R>();
|
||||
}
|
||||
|
||||
template <typename ... Ts>
|
||||
auto operator()(std::tuple<Ts...> && x)
|
||||
{
|
||||
return [&]<std::size_t ... I>(std::index_sequence<I...>){
|
||||
return std::tuple{
|
||||
f(std::get<I>(x))...
|
||||
};
|
||||
}(std::make_index_sequence<sizeof...(Ts)>{});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue