yymp is a library of some miscellaneous items I've created:
yymp::typelistand accompanying templates for manipulation;yymp::wref_tuple, a tuple for providing a flat view of multiple tuple references;yymp::stuple, an aggregate tuple with a focus on improved compilation times.
- A C++ compiler supporting C++20
To include all the typelist facilities, simply #include <yymp/typelist.hpp>.
To create a typelist, one writes
using my_types = yymp::typelist<int, char*, int, void*>;Sometimes, it may be necessary to join two or more typelists together:
using foo_types = yymp::typelist<void, void, short>;
using my_joined_types = yymp::typelist_join_t<foo_types, my_types, foo_types>;
// -> yymp::typelist<void, void, short, int, char*, int, void*, void, void, short>;Other times, we may have a typelist of typelists that we need to combine:
using recombined_typelist = yymp::typelist_expand_trait_t<
yymp::typelist_join,
TypeListOfTypeLists
>;One can also group types by a TransformationTrait, where the key for a type
T is given by TransformationTrait<T>::type. As UnaryTypeTraits
satisfy this requirement, that means the following is possible:
using my_groups = yymp::typelist_group_by_t<std::is_pointer, my_types>;
// -> yymp::typelist<yymp::typelist<int, int>, yymp::typelist<char*, void*>>The order in which the groups appear is by first occurrence.
If instead you want only the types which are pointers, then one can use yymp::filter:
using filtered_types = yymp::typelist_filter_t<std::is_pointer, my_types>;
// -> yymp::typelist<char*, void*>;Or perhaps you need to ensure there are no duplicates:
using no_duplicates = yymp::typelist_filter_duplicates_t<my_joined_types>;
// -> yymp::typelist<void, short, int, char*, void*>;See yymp/typelist.hpp for more.
The following concepts may also be of interest, even if you are not dealing with typelists directly:
// Passes if there is EXACTLY one occurrence of T among Types
template<typename T, typename... Types>
concept unique_among = ...;
// Passes if there is AT LEAST one occurrence of T among Types
template<typename T, typename... Types>
concept any_among = ...;For a potential use where yymp::stuple is a clear winner over std::tuple,
see the stuple stress test preamble.
Your own results may differ, depending on the implementation's std::tuple.
yymp is licensed under the Boost Software License.