//------------------------------------------------------------------------------ /* This file is part of Beast: https://github.com/vinniefalco/Beast Copyright 2013, Vinnie Falco Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #ifndef BEAST_CXX14_UTILITY_H_INCLUDED #define BEAST_CXX14_UTILITY_H_INCLUDED #include "config.h" #include #include #include namespace std { template struct integer_sequence { typedef T value_type; static_assert (is_integral::value, "std::integer_sequence can only be instantiated with an integral type" ); static const size_t static_size = sizeof...(Ints); static /* constexpr */ size_t size() /* noexcept */ { return sizeof...(Ints); } }; template using index_sequence = integer_sequence ; namespace detail { // This workaround is needed for msvc broken sizeof... template struct sizeof_workaround { static size_t const size = sizeof... (Args); }; } // detail #ifdef _MSC_VER // This implementation compiles on MSVC and clang but not gcc namespace detail { template struct make_integer_sequence_unchecked; template struct make_integer_sequence_unchecked < T, N, integer_sequence > { typedef typename make_integer_sequence_unchecked< T, N-1, integer_sequence>::type type; }; template struct make_integer_sequence_unchecked < T, 0, integer_sequence> { typedef integer_sequence type; }; template struct make_integer_sequence_checked { static_assert (is_integral ::value, "T must be an integral type"); static_assert (N >= 0, "N must be non-negative"); typedef typename make_integer_sequence_unchecked < T, N, integer_sequence>::type type; }; } // detail template using make_integer_sequence = typename detail::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 namespace detail { template struct index_tuple { typedef index_tuple next; }; template struct build_index_tuple { typedef typename build_index_tuple ::type::next type; }; template <> struct build_index_tuple <0> { typedef index_tuple<> type; }; template ::type > struct make_integer_sequence; template struct make_integer_sequence > { static_assert (is_integral ::value, "T must be an integral type"); static_assert (N >= 0, "N must be non-negative"); typedef integer_sequence (Ints)...> type; }; } // detail template using make_integer_sequence = typename detail::make_integer_sequence ::type; template using make_index_sequence = make_integer_sequence ; template using index_sequence_for = make_index_sequence ::size>; #endif } #endif