Source code

An C++11 implementation of C++14’s compile-time integer sequences, along with some utilities.

These constructs are typically used to implement the indices trick

template<class T, std::size_t N>
using tl::make_integer_sequence = magic

Creates a tl::integer_sequence from 0 to N-1.


tl::make_integer_sequence<int, 3>; //tl::integer_sequence<int,0,1,2>
template<std::size_t... Idx>
using tl::index_sequence = integer_sequence<std::size_t, Idx...>

Alias for integer sequences of type std::size_t, which comes up a lot with utilities like std::get.

template<std::size_t N>
using tl::make_index_sequence = make_integer_sequence<std::size_t, N>

Alias for making an integer sequence of std::size_t s.

template<class ...Ts>
using tl::index_sequence_for = make_index_sequence<sizeof(Ts...)>

Make an index sequence to index a parameter pack.

template<std::size_t From, std::size_t N>
using tl::make_index_range = magic

Make in index sequence spanning the specified range.


make_index_range<3,2>; //tl::index_sequence<3,4>
make_index_range<5,4>; //tl::index_sequence<5,6,7,8>