1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix index_tuple

This commit is contained in:
bolero-MURAKAMI 2013-01-25 15:14:29 +09:00
parent 48f1b2d615
commit ee8602f6a3
42 changed files with 927 additions and 101 deletions

View file

@ -6,7 +6,9 @@
namespace sprout {
namespace detail {
template<typename IndexTupleType>
struct make_indexes_helper {
struct make_indexes_helper
: public IndexTupleType::type
{
public:
typedef typename IndexTupleType::type type;
public:

View file

@ -32,8 +32,7 @@ namespace sprout {
struct index_n_impl;
template<sprout::index_t I, std::size_t N>
struct index_n_impl<
I,
N,
I, N,
typename std::enable_if<(N == 0)>::type
> {
public:
@ -41,8 +40,7 @@ namespace sprout {
};
template<sprout::index_t I, std::size_t N>
struct index_n_impl<
I,
N,
I, N,
typename std::enable_if<(N == 1)>::type
> {
public:
@ -50,8 +48,7 @@ namespace sprout {
};
template<sprout::index_t I, std::size_t N>
struct index_n_impl<
I,
N,
I, N,
typename std::enable_if<(N > 1 && N % 2 == 0)>::type
>
: public sprout::detail::index_n_next<
@ -60,8 +57,7 @@ namespace sprout {
{};
template<sprout::index_t I, std::size_t N>
struct index_n_impl<
I,
N,
I, N,
typename std::enable_if<(N > 1 && N % 2 == 1)>::type
>
: public sprout::detail::index_n_next2<

View file

@ -32,9 +32,7 @@ namespace sprout {
struct index_range_impl;
template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl<
First,
Step,
N,
First, Step, N,
typename std::enable_if<(N == 0)>::type
> {
public:
@ -42,9 +40,7 @@ namespace sprout {
};
template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl<
First,
Step,
N,
First, Step, N,
typename std::enable_if<(N == 1)>::type
> {
public:
@ -52,9 +48,7 @@ namespace sprout {
};
template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl<
First,
Step,
N,
First, Step, N,
typename std::enable_if<(N > 1 && N % 2 == 0)>::type
>
: public sprout::detail::index_range_next<
@ -64,9 +58,7 @@ namespace sprout {
{};
template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl<
First,
Step,
N,
First, Step, N,
typename std::enable_if<(N > 1 && N % 2 == 1)>::type
>
: public sprout::detail::index_range_next2<
@ -80,9 +72,7 @@ namespace sprout {
struct index_range
: public sprout::detail::make_indexes_helper<
sprout::detail::index_range_impl<
First,
Step,
((Last - First) + (Step - 1)) / Step
First, Step, ((Last - First) + (Step - 1)) / Step
>
>
{};

View file

@ -17,7 +17,12 @@ namespace sprout {
struct index_tuple {
public:
typedef index_tuple type;
typedef sprout::index_t value_type;
public:
SPROUT_STATIC_CONSTEXPR std::size_t size = sizeof...(Indexes);
};
template<sprout::index_t... Indexes>
SPROUT_CONSTEXPR_OR_CONST std::size_t sprout::index_tuple<Indexes...>::size;
} // namespace sprout
#endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP

View file

@ -2,6 +2,7 @@
#define SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple/index_range.hpp>
#include <sprout/index_tuple/detail/make_indexes_helper.hpp>
namespace sprout {

View file

@ -0,0 +1,37 @@
#ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP
#define SPROUT_INDEX_TUPLE_TUPLE_HPP
#include <cstddef>
#include <tuple>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/index_tuple/index_tuple.hpp>
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
//
// tuple_size
//
template<sprout::index_t... Indexes>
struct tuple_size<sprout::index_tuple<Indexes...> >
: public std::integral_constant<std::size_t, sizeof...(Indexes)>
{};
//
// tuple_element
//
template<std::size_t I, sprout::index_t... Indexes>
struct tuple_element<I, sprout::index_tuple<Indexes...> > {
static_assert(I < sizeof...(Indexes), "tuple_element<>: index out of range");
public:
typedef sprout::index_t type;
};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP