41 #ifndef LIB_META_TUPLE_HELPER_H 42 #define LIB_META_TUPLE_HELPER_H 71 template<
typename...TYPES>
76 template<
typename...TYPES>
85 using disable_if_Tuple = lib::meta::disable_if<lib::meta::is_Tuple<std::remove_reference_t<TUP>>>;
96 template<
class TUP,
class FUN,
typename = enable_if_Tuple<TUP>>
100 std::apply ([&fun](
auto&&... elms)
102 (fun (std::forward<decltype(elms)> (elms)), ...);
104 ,std::forward<TUP> (tuple));
121 template<
class TUP,
class FUN,
typename = enable_if_Tuple<TUP>>
125 return std::apply ([&fun](
auto&&... elms)
127 using Tuple = std::tuple<decltype(fun (std::forward<decltype(elms)> (elms))) ...>;
128 return Tuple (fun (std::forward<decltype(elms)> (elms)) ...);
130 ,std::forward<TUP> (tuple));
139 template<
typename SEQ>
144 template<
typename...TYPES>
147 using Type = std::tuple<TYPES...>;
154 template<
typename...TYPES>
162 template<
class H,
typename TAIL>
185 template<
typename TYPES>
186 using Tuple =
typename BuildTupleType<TYPES>::Type;
189 using std::tuple_size;
190 using std::tuple_element;
195 template<
typename...TYPES>
198 using Seq =
typename Types<TYPES...>::Seq;
199 using List =
typename Seq::List;
201 template<
typename...TYPES>
204 using Seq =
typename Types<TYPES...>::Seq;
205 using List =
typename Seq::List;
235 template<
typename TYPES
236 ,
template<
class,
class,
size_t>
class _ElmMapper_
245 template<
class SRC,
size_t...idx>
247 :
Tuple<TYPES> (_ElmMapper_<SRC,
Tuple<TYPES>, idx>{values}...)
267 template<
class SRC,
class TAR>
271 template<
class SRC,
class TAR,
size_t i>
284 template<
typename TYPES,
class SRC>
317 <
template<
class,
class,
class, u
int>
class _X_
342 <
template<
class,
class,
class, u
int>
class _X_
349 using Product = _X_<NullType, TUP, TUP, i>;
373 dump (std::string
const& prefix =
"(")
const 375 return BASE::dump (prefix + util::toString(std::get<idx>(*
this))+
",");
379 template<
class TUP, u
int n>
388 dump (std::string
const& prefix =
"(")
const 390 if (1 < prefix.length())
392 return prefix.substr (0, prefix.length()-1) +
")";
407 template<
typename...TYPES>
409 dump (std::tuple<TYPES...>
const& tuple)
412 using Displayer =
typename BuildAccessor::Product ;
414 return static_cast<Displayer const&
> (tuple)
426 template<
typename...TYPES>
430 invoke (std::tuple<TYPES...>
const& tuple) noexcept
432 return "«"+typeStr(tuple)
433 +
"»──" + lib::meta::dump (tuple);
435 catch(...) {
return FAILURE_INDICATOR; }
A template metaprogramming technique for manipulating collections of types.
typename BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
Metaprogramming: simple helpers for working with lists-of-types.
Some basic facilities for manipulating type sequences.
Tuple< TYPES > buildTuple(SRC values)
convenience shortcut to build a tuple from some suitable source data.
Implementation namespace for support and library code.
void forEach(TUP &&tuple, FUN fun)
Tuple iteration: perform some arbitrary operation on each element of a tuple.
failsafe invocation of custom string conversion.
auto mapEach(TUP &&tuple, FUN fun)
Apply some arbitrary function onto all elements of a tuple.
Metaprogramming with type sequences based on variadic template parameters.
std::string dump(std::tuple< TYPES... > const &tuple)
convenience function to dump a given tuple's contents.