// // Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) // // 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 BEAST_DETAIL_INTEGER_SEQUENCE_H_INCLUDED #define BEAST_DETAIL_INTEGER_SEQUENCE_H_INCLUDED #include #include #include namespace beast { namespace detail { template struct integer_sequence { using value_type = T; static_assert (std::is_integral::value, "std::integer_sequence can only be instantiated with an integral type" ); static std::size_t constexpr static_size = sizeof...(Ints); static std::size_t constexpr size() { return sizeof...(Ints); } }; template using index_sequence = integer_sequence; // This workaround is needed for broken sizeof... template struct sizeof_workaround { static std::size_t constexpr size = sizeof... (Args); }; #ifdef _MSC_VER // This implementation compiles on MSVC and clang but not gcc template struct make_integer_sequence_unchecked; template struct make_integer_sequence_unchecked< T, N, integer_sequence> { using type = typename make_integer_sequence_unchecked< T, N-1, integer_sequence>::type; }; template struct make_integer_sequence_unchecked< T, 0, integer_sequence> { using type = integer_sequence; }; template struct make_integer_sequence_checked { static_assert (std::is_integral::value, "T must be an integral type"); static_assert (N >= 0, "N must be non-negative"); using type = typename make_integer_sequence_unchecked< T, N, integer_sequence>::type; }; template using make_integer_sequence = typename make_integer_sequence_checked::type; template using make_index_sequence = make_integer_sequence; template using index_sequence_for = make_index_sequence::size>; #else // This implementation compiles on gcc but not MSVC template struct index_tuple { using next = index_tuple; }; template struct build_index_tuple { using type = typename build_index_tuple::type::next; }; template<> struct build_index_tuple<0> { using type = index_tuple<>; }; template::type > struct integer_sequence_helper; template struct integer_sequence_helper> { static_assert (std::is_integral::value, "T must be an integral type"); static_assert (N >= 0, "N must be non-negative"); using type = integer_sequence (Ints)...>; }; template using make_integer_sequence = typename integer_sequence_helper::type; template using make_index_sequence = make_integer_sequence; template using index_sequence_for = make_index_sequence::size>; #endif } // detail } // beast #endif