7#include <dune/common/tuplevector.hh>
8#include <amdis/common/Apply.hpp>
25template <
class F,
class T>
26auto map(F&& f, T
const& t)
28 return Map<T>::impl(f,t);
39 static auto impl(F&& f, T
const& t)
45template <
class T, std::
size_t n>
46struct Map<std::array<T,n>>
49 static auto impl(F&& f, std::array<T,n>
const& a)
51 return Ranges::applyIndices<n>([&](
auto... ii) {
52 return std::array{Recursive::map(f,a[ii])...}; });
57struct Map<std::tuple<TT...>>
60 static auto impl(F&& f, std::tuple<TT...>
const& t)
62 return Ranges::apply([&](
auto const&... ti) {
63 return std::tuple{Recursive::map(f,ti)...}; }, t);
67template <
class T1,
class T2>
68struct Map<std::pair<T1,T2>>
71 static auto impl(F&& f, std::pair<T1,T2>
const& t)
73 return std::pair{Recursive::map(f,t.first), Recursive::map(f,t.second)};
78struct Map<Dune::TupleVector<TT...>>
81 static auto impl(F&& f, Dune::TupleVector<TT...>
const& t)
83 return Ranges::apply([&](
auto const&... ti) {
84 return Dune::makeTupleVector(Recursive::map(f,ti)...); }, t);
89struct Map<std::vector<T>>
92 static auto impl(F&& f, std::vector<T>
const& v)
94 using U = TYPEOF(Recursive::map(f,std::declval<T>()));
96 out.reserve(v.size());
97 for (std::size_t i = 0; i < v.size(); ++i)
98 out.emplace_back(Recursive::map(f,v[i]));
Default implementation of the recursive map function.
Definition: Map.hpp:37