|
|
|
|
@@ -91,13 +91,13 @@ namespace fennec
|
|
|
|
|
/// \endcode
|
|
|
|
|
/// \tparam ValueT type of the values
|
|
|
|
|
/// \tparam Values sequence values
|
|
|
|
|
template<typename ValueT, ValueT...Values> struct sequence
|
|
|
|
|
template<typename ValueT, ValueT...Values> struct const_sequence
|
|
|
|
|
{
|
|
|
|
|
/// \brief type of the sequence
|
|
|
|
|
using value_type = ValueT;
|
|
|
|
|
|
|
|
|
|
/// \brief self-referential type
|
|
|
|
|
using type = sequence;
|
|
|
|
|
using type = const_sequence;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// \brief returns the number of elements
|
|
|
|
|
@@ -119,13 +119,13 @@ template<typename ValueT, ValueT...Values> struct sequence
|
|
|
|
|
/// \tparam IntT type of the values, must satisfy ```fennec::is_integral<T>```
|
|
|
|
|
/// \tparam Values sequence values
|
|
|
|
|
template<typename IntT, IntT...Values> requires(is_integral_v<IntT>)
|
|
|
|
|
struct integer_sequence : sequence<IntT, Values...>
|
|
|
|
|
struct const_integer_sequence : const_sequence<IntT, Values...>
|
|
|
|
|
{
|
|
|
|
|
/// \brief type of the sequence
|
|
|
|
|
using value_type = IntT;
|
|
|
|
|
|
|
|
|
|
/// \brief self-referential type
|
|
|
|
|
using type = integer_sequence;
|
|
|
|
|
using type = const_integer_sequence;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// \brief returns the number of elements
|
|
|
|
|
@@ -158,13 +158,13 @@ template<typename IntT, size_t N> using make_integer_sequence_t = typename make
|
|
|
|
|
///
|
|
|
|
|
/// \details A `fennec::integer_sequence` specialized for sequences of `size_t` indices.
|
|
|
|
|
/// \tparam Indices sequence values
|
|
|
|
|
template<size_t...Indices> struct index_sequence : integer_sequence<size_t, Indices...>
|
|
|
|
|
template<size_t...Indices> struct const_index_sequence : const_integer_sequence<size_t, Indices...>
|
|
|
|
|
{
|
|
|
|
|
/// \brief type of the sequence
|
|
|
|
|
using value_type = size_t;
|
|
|
|
|
|
|
|
|
|
/// \brief self-referential type
|
|
|
|
|
using type = index_sequence;
|
|
|
|
|
using type = const_index_sequence;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// \brief returns the number of elements
|
|
|
|
|
@@ -213,31 +213,31 @@ template<typename SequenceT0, typename SequenceT1> using concat_sequence_t
|
|
|
|
|
template<typename T, size_t N> struct make_integer_sequence : concat_sequence_t<make_integer_sequence_t<T, N / 2>, make_integer_sequence_t<T, N - N / 2>>{};
|
|
|
|
|
|
|
|
|
|
// Base Case of N=0
|
|
|
|
|
template<typename T> struct make_integer_sequence<T, 0> : integer_sequence<T> {};
|
|
|
|
|
template<typename T> struct make_integer_sequence<T, 0> : const_integer_sequence<T> {};
|
|
|
|
|
|
|
|
|
|
// Base Case of N=1
|
|
|
|
|
template<typename T> struct make_integer_sequence<T, 1> : integer_sequence<T, 0>{};
|
|
|
|
|
template<typename T> struct make_integer_sequence<T, 1> : const_integer_sequence<T, 0>{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Implementation for Generating an index_sequence
|
|
|
|
|
template<size_t N> struct make_index_sequence : concat_sequence_t<make_index_sequence_t<N / 2>, make_index_sequence_t<N - N / 2>>{};
|
|
|
|
|
|
|
|
|
|
// Base Case of N=0
|
|
|
|
|
template<> struct make_index_sequence<0> : index_sequence<> {};
|
|
|
|
|
template<> struct make_index_sequence<0> : const_index_sequence<> {};
|
|
|
|
|
|
|
|
|
|
// Base Case of N=1
|
|
|
|
|
template<> struct make_index_sequence<1> : index_sequence<0>{};
|
|
|
|
|
template<> struct make_index_sequence<1> : const_index_sequence<0>{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Specialization for integer sequences
|
|
|
|
|
template<typename T, T...SequenceV0, T...SequenceV1>
|
|
|
|
|
struct concat_sequence<integer_sequence<T, SequenceV0...>, integer_sequence<T, SequenceV1...>>
|
|
|
|
|
: integer_sequence<T, SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
|
|
|
|
|
struct concat_sequence<const_integer_sequence<T, SequenceV0...>, const_integer_sequence<T, SequenceV1...>>
|
|
|
|
|
: const_integer_sequence<T, SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
|
|
|
|
|
|
|
|
|
|
// Specialization for index sequences
|
|
|
|
|
template<size_t...SequenceV0, size_t...SequenceV1>
|
|
|
|
|
struct concat_sequence<index_sequence<SequenceV0...>, index_sequence<SequenceV1...>>
|
|
|
|
|
: index_sequence<SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
|
|
|
|
|
struct concat_sequence<const_index_sequence<SequenceV0...>, const_index_sequence<SequenceV1...>>
|
|
|
|
|
: const_index_sequence<SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|