List Operations

The following type functions are used to operate on lists in various ways.

template<class ...Ls>
using core::mp::intersect_t = typename intersect<Ls...>::type

Intersect the given type lists Ls.

intersect_t<list<int,char>,list<int>> // list<int>

Template Parameters:

Ls – The type lists to intersect.

template<typename S, typename T>
using core::mp::permutation_t = typename permutation<S, T>::type

Compute the permutation vector that maps type list S to type list T.

permutation_t<list<int,char>,list<char,int>> // list<mp_1s, mp_0s>

Template Parameters:
  • S – The initial type list.

  • T – The permuted type list.

template<typename V, typename L>
using core::mp::remove_t = typename remove<V, L>::type

Remove all occurrences of type V from the type list L

remove_t<int,list<int,char,int>> // list<char>

Template Parameters:
  • V – The type to remove.

  • L – The type list.

template<typename S, typename L>
using core::mp::remove_list_t = typename remove_list<S, L>::type

Remove all occurrences of the types in type list S from the type list L

remove_list_t<list<int,char>,list<int,char,int>> // list<>

Template Parameters:
  • S – The list of types to remove.

  • L – The type list.

template<typename L, template<typename, typename> typename C>
using core::mp::sort_t = typename sort<L, C>::type

Sort the types in type list L according to the template template comparator C.

The comparator should be a template template parameter taking two types that evaluates to true if the first type compares less than the second type; otherwise, false.

sort_t<list<mp_c,mp_b,mp_a>,integral_constant_less> // list<mp_a,mp_b,mp_c>

Template Parameters:
  • L – The type list to sort.

  • C – The template template comparator

template<typename L1, typename L2>
using core::mp::subtract_t = typename subtract<L1, L2, size_v<L1>>::type

Removes all occurrences of the types in type list L2 from type list L1.

Template Parameters:
  • L1 – The type list to subtract from.

  • L2 – A type list of the types to remove from L1.

template<size_t I, size_t J, typename L>
using core::mp::swap_t = typename swap<I, J, L>::type

Swap entries at indices I and J in type list L.

swap_t<1,3,list<mp_a,mp_b,mp_c,mp_d>> // list<mp_a,mp_d,mp_c,mp_b>

Template Parameters:
  • I – The first index.

  • J – The second index.

template<template<typename...> typename F, typename L>
using core::mp::transform_t = typename transform<F, L>::type

Apply the template template parameter F to each element of type list L.

The template template parameter F should be a template with a single type parameter that evaluates to the transformed type.

Template Parameters:
  • F – Template template parameter that computes transformation.

  • L – The type list to transform.

template<class ...Ls>
using core::mp::union_t = unique_t<cat_t<Ls...>>

Union of the given lists.

This is a proper mathematical set union in that there are no duplicate members in the resulting type list.

Template Parameters:
  • Ls... – The lists to combine

  • Ls – The type lists to union.

Return:

The union of the given lists Compute the union of the given type lists Ls.

template<class L>
using core::mp::unique_t = typename unique<L>::type

Uniquify type list L, i.e. remove any duplicate types.

Template Parameters:

L – The type list to uniquify.