mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
type_list_join added
This commit is contained in:
19
src/include/units/bits/external/type_list.h
vendored
19
src/include/units/bits/external/type_list.h
vendored
@@ -73,6 +73,25 @@ namespace units {
|
||||
template<TypeList List, typename... Types>
|
||||
using type_list_push_back = detail::type_list_push_back_impl<List, Types...>::type;
|
||||
|
||||
// join
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename List, typename... Rest>
|
||||
struct type_list_join_impl {
|
||||
using type = List;
|
||||
};
|
||||
|
||||
template<template<typename...> typename List, typename... First, typename... Second, typename... Rest>
|
||||
struct type_list_join_impl<List<First...>, List<Second...>, Rest...> {
|
||||
using type = type_list_join_impl<List<First..., Second...>, Rest...>::type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<TypeList... Lists>
|
||||
using type_list_join = detail::type_list_join_impl<Lists...>::type;
|
||||
|
||||
// split
|
||||
|
||||
namespace detail {
|
||||
|
@@ -44,6 +44,15 @@ static_assert(std::is_same_v<type_list_push_back<type_list<>, int>, type_list<in
|
||||
static_assert(std::is_same_v<type_list_push_back<type_list<>, int, long, double>, type_list<int, long, double>>);
|
||||
static_assert(std::is_same_v<type_list_push_back<type_list<double>, int, long>, type_list<double, int, long>>);
|
||||
|
||||
static_assert(std::is_same_v<type_list_join<type_list<>>, type_list<>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>>, type_list<>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>, type_list<>>, type_list<>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<int>, type_list<>, type_list<>>, type_list<int>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<int>, type_list<>>, type_list<int>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>, type_list<int>>, type_list<int>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<int>, type_list<float>, type_list<bool>>, type_list<int, float, bool>>);
|
||||
static_assert(std::is_same_v<type_list_join<type_list<int, short>, type_list<float, double>, type_list<bool>>, type_list<int, short, float, double, bool>>);
|
||||
|
||||
// type_list_split
|
||||
|
||||
static_assert(std::is_same_v<type_list_split<type_list<int>, 0>::first_list, type_list<>>);
|
||||
|
Reference in New Issue
Block a user