Metaprogramming with tuples-of-types and the std::tuple record.
This header complements typelist.hpp and provides a bridge from type sequences to the tuple type provided by the standard library, including traits and helpers to build tuple types from metaprogramming and to pretty-print tuples.
Notably, a concept tuple_like is provided, which is satisfied for any type in compliance with the »tuple protocol«. Together with a [generic accessor][lib::meta::getElm], this allows to handle all tuple-like types uniformly.
- Note
- Due to an unfortunate limitation of the standard, we're forced to provide our own alternative implementation to replace
std::apply, so that a function can be applied to any tuple-like
Furthermore, a generic iteration construct is provided, to instantiate a generic Lambda for each element of a given tuple, which allows to write generic code »for each tuple element«.
- See also
- control::CommandDef usage example
-
TupleHelper_test
-
typelist.hpp
-
function.hpp
-
generator.hpp
Definition in file tuple-helper.hpp.
|
| struct | is_Tuple< T > |
| | trait to detect tuple types More...
|
| |
| struct | is_Tuple< std::tuple< TYPES... > > |
| |
| struct | is_Tuple< const std::tuple< TYPES... > > |
| |
| struct | _InvokeMetafunTup< META, FUN, TUP > |
| |
| struct | _InvokeMetafunTup< META, FUN, TUP & > |
| |
| struct | ElmTypes< TUP > |
| | Specialisation of variadic access for any tuple-like. More...
|
| |
| struct | BuildTupleType< SEQ > |
| |
| struct | BuildTupleType< Types< TYPES... > > |
| |
| struct | BuildTupleType< Node< H, TAIL > > |
| |
| struct | BuildTupleType< Nil > |
| |
| struct | RebindTupleTypes< TYPES > |
| | match and rebind the type sequence from a tuple More...
|
| |
| struct | RebindTupleTypes< std::tuple< TYPES... > > |
| |
| struct | TupleConstructor< TYPES, _ElmMapper_ > |
| | Extensible Adapter to construct a distinct tuple from some arbitrary source type. More...
|
| |
| class | BuildTupleAccessor< _X_, TYPES, TUP, i > |
| | Decorating a tuple type with auxiliary data access operations. More...
|
| |
| class | BuildTupleAccessor< _X_, Types<>, TUP, i > |
| |
| struct | TupleElementDisplayer< TY, BASE, TUP, idx > |
| | Helper to dump tuple contents. More...
|
| |
| struct | TupleElementDisplayer< Nil, TUP, TUP, n > |
| |
| struct | StringConv< std::tuple< TYPES... > > |
| |
|
| template<typename TY > |
| std::string | toString (TY const &val) noexcept |
| | get some string representation of any object, reliably.
|
| |
template<std::size_t idx, class TUP >
requires (tuple_like<std::remove_reference_t<TUP>>) |
| decltype(auto) | getElm (TUP &&tup) |
| | Helper for abstracted / unified access to member elements of any tuple-like
|
| |
| template<typename FUN , typename TUP , size_t... Idx> |
| constexpr decltype(auto) | __unpack_and_apply (FUN &&f, TUP &&tup, std::index_sequence< Idx... >) |
| |
template<class FUN , class TUP >
requires (tuple_like<remove_reference_t<TUP>>) |
| constexpr decltype(auto) | apply (FUN &&f, TUP &&tup) noexcept(can_nothrow_invoke_tup< FUN, TUP >) |
| | Replacement for std::apply — yet applicable to tuple-like custom types.
|
| |
template<class TUP , class FUN >
requires (tuple_like<remove_reference_t<TUP>>) |
| constexpr void | forEach (TUP &&tuple, FUN fun) |
| | Tuple iteration: perform some arbitrary operation on each element of a tuple.
|
| |
template<class TUP , class FUN >
requires (tuple_like<remove_reference_t<TUP>>) |
| constexpr auto | mapEach (TUP &&tuple, FUN fun) |
| | Apply some arbitrary function onto all elements of a tuple.
|
| |
| template<typename TYPES , class SRC > |
| Tuple< TYPES > | buildTuple (SRC &&values) |
| | convenience shortcut to build a tuple from some suitable source data.
|
| |
| template<typename... TYPES> |
| std::string | dump (std::tuple< TYPES... > const &tuple) |
| | convenience function to dump a given tuple's contents.
|
| |