//======================================================================= // Copyright Baptiste Wicht 2013-2016. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #ifndef TSTL_INTEGER_SEQUENCE_H #define TSTL_INTEGER_SEQUENCE_H #include #include namespace std { template struct integer_sequence { static constexpr size_t size() noexcept { return sizeof...(Values); } }; template using index_sequence = integer_sequence; template struct sequence_concat_impl; template struct sequence_concat_impl, N, false> { using type = integer_sequence; }; template struct sequence_concat_impl, N, true> { using type = integer_sequence; }; // The 0 and 1 cannot be deduced directly, must use SFINAE // Base type for generating a sequence template struct make_integer_sequence_impl; // The general case construct a list by concatenating template struct make_integer_sequence_impl { using type = typename sequence_concat_impl::type, N / 2, N % 2 == 1>::type; }; // Specialization for empty sequence template struct make_integer_sequence_impl> { using type = integer_sequence; }; // Specialization for sequence of length one template struct make_integer_sequence_impl> { using type = integer_sequence; }; template using make_integer_sequence = typename make_integer_sequence_impl::type; template using make_index_sequence = make_integer_sequence; } //end of namespace std #endif