1 /*=============================================================================
2 Copyright (c) 2015 Agustin K-ballo Berge
3 Copyright (c) 2015 Kohei Takahashi
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
9 #ifndef BOOST_FUSION_SUPPORT_DETAIL_INDEX_SEQUENCE_06232015_1038
10 #define BOOST_FUSION_SUPPORT_DETAIL_INDEX_SEQUENCE_06232015_1038
12 #include <boost/fusion/support/config.hpp>
15 // GCC5 has O(logN) implementation, see https://gcc.gnu.org/PR66059 .
16 #if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304) \
17 || (defined(BOOST_LIBSTDCXX_VERSION) \
18 && BOOST_LIBSTDCXX_VERSION >= 500000 && __cplusplus >= 201402)
20 #define BOOST_FUSION_STDLIB_HAS_INTEGER_SEQUENCE
23 namespace boost { namespace fusion { namespace detail
25 #ifdef BOOST_FUSION_STDLIB_HAS_INTEGER_SEQUENCE
26 // Use aliasing templates without checking availability, the compiler should work.
27 template <std::size_t ...Ints>
28 using index_sequence = std::index_sequence<Ints...>;
30 template <std::size_t N>
31 struct make_index_sequence
33 using type = std::make_index_sequence<N>;
36 template <std::size_t ...Ints>
39 typedef std::size_t value_type;
41 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
42 static std::size_t size() BOOST_NOEXCEPT
43 { return sizeof...(Ints); }
45 // non standard extension
46 typedef index_sequence type;
49 template <typename Left, typename Right>
50 struct _make_index_sequence_join;
52 template <std::size_t... Left, std::size_t... Right>
53 struct _make_index_sequence_join<
54 index_sequence<Left...>, index_sequence<Right...>
55 > : index_sequence<Left..., (sizeof...(Left) + Right)...>
58 template <std::size_t N>
59 struct make_index_sequence
60 : _make_index_sequence_join<
61 typename make_index_sequence<N / 2>::type
62 , typename make_index_sequence<N - N / 2>::type
67 struct make_index_sequence<1>
72 struct make_index_sequence<0>