forked from boostorg/fusion
Split c++14 like index_sequence into support/detail.
This commit is contained in:
59
include/boost/fusion/support/detail/index_sequence.hpp
Normal file
59
include/boost/fusion/support/detail/index_sequence.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2015 Agustin K-ballo Berge
|
||||
Copyright (c) 2015 Kohei Takahashi
|
||||
|
||||
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 BOOST_FUSION_SUPPORT_DETAIL_INDEX_SEQUENCE_06232015_1038
|
||||
#define BOOST_FUSION_SUPPORT_DETAIL_INDEX_SEQUENCE_06232015_1038
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <std::size_t ...Ints>
|
||||
struct index_sequence
|
||||
{
|
||||
typedef std::size_t value_type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static std::size_t size() BOOST_NOEXCEPT
|
||||
{ return sizeof...(Ints); }
|
||||
|
||||
// non standard extension
|
||||
typedef index_sequence type;
|
||||
};
|
||||
|
||||
template <typename Left, typename Right>
|
||||
struct _make_index_sequence_join;
|
||||
|
||||
template <std::size_t... Left, std::size_t... Right>
|
||||
struct _make_index_sequence_join<
|
||||
index_sequence<Left...>, index_sequence<Right...>
|
||||
> : index_sequence<Left..., (sizeof...(Left) + Right)...>
|
||||
{};
|
||||
|
||||
template <std::size_t N>
|
||||
struct make_index_sequence
|
||||
: _make_index_sequence_join<
|
||||
typename make_index_sequence<N / 2>::type
|
||||
, typename make_index_sequence<N - N / 2>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct make_index_sequence<1>
|
||||
: index_sequence<0>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct make_index_sequence<0>
|
||||
: index_sequence<>
|
||||
{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user