summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-06-01 11:49:15 +0200
committerMolly Lloyd <mollymerp@users.noreply.github.com>2018-08-31 13:08:47 -0700
commit5e9bbfdd44ef9c0a2c5850566c28a40aa2a05151 (patch)
treec988c26ea070063adb4a584485625ac5e7ec2ec5 /include
parent748e6bde5f611cfba3419c272d3cbf1d5c1350ef (diff)
downloadqtlocation-mapboxgl-5e9bbfdd44ef9c0a2c5850566c28a40aa2a05151.tar.gz
[core] introduce TypeListConcat and TypeList::ExpandInto
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/type_list.hpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/include/mbgl/util/type_list.hpp b/include/mbgl/util/type_list.hpp
index 4a5e95c8a4..1b594bf7f6 100644
--- a/include/mbgl/util/type_list.hpp
+++ b/include/mbgl/util/type_list.hpp
@@ -5,8 +5,11 @@
namespace mbgl {
-template <class...>
-class TypeList {};
+template <class... Ts>
+struct TypeList {
+ template <template <class...> class T, class... Ps>
+ using ExpandInto = T<Ps..., Ts...>;
+};
namespace detail {
@@ -32,9 +35,30 @@ struct TypeFilter<TypeList<T, Ts...>, Predicate> {
using Type = std::conditional_t<Predicate<T>::value, typename TypeCons<T, Tail>::Type, Tail>;
};
+template <class...>
+struct TypeListConcat;
+
+template <>
+struct TypeListConcat<> {
+ using Type = TypeList<>;
+};
+
+template <class... As>
+struct TypeListConcat<TypeList<As...>> {
+ using Type = TypeList<As...>;
+};
+
+template <class... As, class... Bs, class... Rs>
+struct TypeListConcat<TypeList<As...>, TypeList<Bs...>, Rs...> {
+ using Type = typename TypeListConcat<TypeList<As..., Bs...>, Rs...>::Type;
+};
+
} // namespace detail
template <class TypeList, template <class> class Predicate>
using FilteredTypeList = typename detail::TypeFilter<TypeList, Predicate>::Type;
+template <class... Ts>
+using TypeListConcat = typename detail::TypeListConcat<Ts...>::Type;
+
} // namespace mbgl