mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
最初
This commit is contained in:
commit
b3bb8121e8
362 changed files with 16820 additions and 0 deletions
59
sprout/index_tuple.hpp
Normal file
59
sprout/index_tuple.hpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifndef SPROUT_INDEX_TUPLE_HPP
|
||||
#define SPROUT_INDEX_TUPLE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// index_tuple
|
||||
//
|
||||
template<std::ptrdiff_t... Indexes>
|
||||
struct index_tuple {};
|
||||
|
||||
//
|
||||
// index_range
|
||||
//
|
||||
template<
|
||||
std::ptrdiff_t First,
|
||||
std::ptrdiff_t Last,
|
||||
std::ptrdiff_t Step = 1,
|
||||
typename Acc = sprout::index_tuple<>,
|
||||
bool Break = (First >= Last)
|
||||
>
|
||||
struct index_range {
|
||||
typedef Acc type;
|
||||
};
|
||||
template<
|
||||
std::ptrdiff_t First,
|
||||
std::ptrdiff_t Last,
|
||||
std::ptrdiff_t Step,
|
||||
std::ptrdiff_t ...Indexes
|
||||
>
|
||||
struct index_range<First, Last, Step, sprout::index_tuple<Indexes...>, false>
|
||||
: public sprout::index_range<First + Step, Last, Step, sprout::index_tuple<Indexes..., First> >
|
||||
{};
|
||||
|
||||
//
|
||||
// index_n
|
||||
//
|
||||
template<
|
||||
std::ptrdiff_t I,
|
||||
std::ptrdiff_t N,
|
||||
typename Acc = sprout::index_tuple<>,
|
||||
bool Break = (N == 0)
|
||||
>
|
||||
struct index_n {
|
||||
typedef Acc type;
|
||||
};
|
||||
template<
|
||||
std::ptrdiff_t I,
|
||||
std::ptrdiff_t N,
|
||||
std::ptrdiff_t ...Indexes
|
||||
>
|
||||
struct index_n<I, N, sprout::index_tuple<Indexes...>, false>
|
||||
: public sprout::index_n<I, N - 1, sprout::index_tuple<Indexes..., I> >
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_INDEX_TUPLE_HPP
|
Loading…
Add table
Add a link
Reference in a new issue