1 /* 2 Copyright Barrett Adair 2016-2017 3 4 Distributed under the Boost Software License, Version 1.0. 5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 6 */ 7 8 #ifndef BOOST_CLBL_TRTS_DETAIL_POLYFILLS_MAKE_INDEX_SEQUENCE_HPP 9 #define BOOST_CLBL_TRTS_DETAIL_POLYFILLS_MAKE_INDEX_SEQUENCE_HPP 10 11 #undef BOOST_CLBL_TRTS_IX_SEQ 12 #define BOOST_CLBL_TRTS_IX_SEQ(...) \ 13 ::boost::callable_traits::detail::index_sequence<__VA_ARGS__> 14 15 #undef BOOST_CLBL_TRTS_MAKE_IX_SEQ 16 #define BOOST_CLBL_TRTS_MAKE_IX_SEQ(...) \ 17 ::boost::callable_traits::detail::make_index_sequence<__VA_ARGS__> 18 19 namespace boost { namespace callable_traits { namespace detail { 20 21 template<std::size_t...> 22 struct index_sequence { using type = index_sequence; }; 23 24 template<typename, typename> 25 struct concat; 26 27 template<std::size_t... I1, std::size_t... I2> 28 struct concat<index_sequence<I1...>, index_sequence<I2...>> 29 : index_sequence<I1..., (sizeof...(I1)+I2)...> {}; 30 31 template<std::size_t N> 32 struct make_index_sequence_t; 33 34 template<std::size_t N> 35 struct make_index_sequence_t : concat< 36 typename make_index_sequence_t<N/2>::type, 37 typename make_index_sequence_t<N - N/2>::type >::type {}; 38 39 template<> 40 struct make_index_sequence_t<0> : index_sequence<> {}; 41 42 template<> 43 struct make_index_sequence_t<1> : index_sequence<0> {}; 44 45 template<std::size_t... I> 46 using make_index_sequence = typename make_index_sequence_t<I...>::type; 47 48 }}} // namespace boost::callable_traits::detail 49 50 #endif // #ifndef BOOST_CLBL_TRTS_DETAIL_POLYFILLS_MAKE_INDEX_SEQUENCE_HPP 51