Operations¶
The following functions operate on tuples.
-
template<typename F, typename ...Ts, typename Indices = make_tuple_index<nth<0, Ts...>>>
auto core::tp::map(F &&function, const Ts&... tuples)¶ Map function across each stripe of elements in tuples.
The given function is first invoked across the first element of each tuple, i.e.
function(std::get<0>(tuple0), std::get<0>(tuple1), ...)
to produce the first element of the new tuple. And, then, on each successive stripe of elements.- Template Parameters:
F – The function type.
Ts – The tuple types.
- Returns:
A new tuple resulting from mapping function across each stripe of elements. param function The function to map across the given tuples. param tuples The tuples to map across.
-
template<typename F, typename S, typename ...Ts>
auto core::tp::map(std::tuple<Ts...> const &tuple, F &&function, S state)¶ Map function sequentially to each element of tuple passing along state.
- Parameters:
tuple – The source tuple.
function – The function to apply.
state – The initial state.
- Template Parameters:
F – The function type.
S – The state type.
Ts. – The tuple element types.
- Returns:
A new tuple resulting from mapping function across each element.
-
template<class F, class ...Ts, class Indices = make_tuple_index<nth<0, Ts...>>>
auto core::tp::map_inplace(F &&function, Ts&... tuples)¶ Modify tuples inplace by invoking function sequentially on each stripe of tuple elements.
The given function is first invoked on the first element of each tuple, i.e.
function(std::get<0>(tuple0), std::get<0>(tuple1), ...)
. And, then on each successive set of elements.- Parameters:
function – The function to map across the stripes of tuple elements.
tuples – The tuples to modify in place.
- Template Parameters:
F – The function type.
Ts – The tuple types.
-
template<typename F, typename T, typename Indices = make_tuple_index<T>>
auto core::tp::map_ref(F &&function, T const &tuple)¶
-
template<typename F, typename V, typename T, typename Indices = make_tuple_index<T>>
auto core::tp::fold_l(F &&function, V value, T const &tuple)¶ Left fold function over the elements of tuple starting with the given initial value.
- Parameters:
function – The function to left fold across the tuple elements.
value – The initial value of the fold.
tuple – The source tuple.
- Template Parameters:
F – The function type.
V – The initial value type.
T – The tuple type.
- Returns:
The result of left folding function of the tuple elements start with value.
-
template<typename F, typename V, typename T, typename Indices = make_tuple_index<T>>
auto core::tp::fold_r(F &&function, V value, T const &tuple)¶ Right fold function over the elements of tuple starting with the given initial value.
- Parameters:
function – The function to right fold across the tuple elements.
value – The initial value of the fold.
tuple – The source tuple.
- Template Parameters:
F – The function type.
V – The initial value type.
T – The tuple type.
- Returns:
The result of right folding function of the tuple elements start with value.