Sprout/sprout/index_tuple/tuple.hpp

68 lines
1.8 KiB
C++
Raw Normal View History

2013-01-25 06:14:29 +00:00
#ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP
#define SPROUT_INDEX_TUPLE_TUPLE_HPP
#include <cstddef>
#include <tuple>
#include <type_traits>
#include <sprout/config.hpp>
2013-03-31 04:39:26 +00:00
#include <sprout/index_tuple/integer_seq.hpp>
2013-01-25 06:14:29 +00:00
#include <sprout/index_tuple/index_tuple.hpp>
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
2013-03-31 04:39:26 +00:00
//
// tuple_size
//
template<typename T, T... Is>
struct tuple_size<sprout::integer_seq<T, Is...> >
: public std::integral_constant<std::size_t, sizeof...(Is)>
{};
//
// tuple_element
//
template<std::size_t I, typename T, T... Is>
struct tuple_element<I, sprout::integer_seq<T, Is...> > {
static_assert(I < sizeof...(Is), "tuple_element<>: index out of range");
public:
typedef T type;
};
2013-01-25 06:14:29 +00:00
//
// tuple_size
//
template<sprout::index_t... Indexes>
struct tuple_size<sprout::index_tuple<Indexes...> >
2013-03-31 04:39:26 +00:00
: public std::tuple_size<sprout::integer_seq<sprout::index_t, Indexes...> >
2013-01-25 06:14:29 +00:00
{};
//
// tuple_element
//
template<std::size_t I, sprout::index_t... Indexes>
2013-03-31 04:39:26 +00:00
struct tuple_element<I, sprout::index_tuple<Indexes...> >
: public std::tuple_element<I, sprout::integer_seq<sprout::index_t, Indexes...> >
{};
//
// tuple_size
//
template<sprout::uindex_t... Indexes>
struct tuple_size<sprout::uindex_tuple<Indexes...> >
: public std::tuple_size<sprout::integer_seq<sprout::uindex_t, Indexes...> >
{};
//
// tuple_element
//
template<std::size_t I, sprout::uindex_t... Indexes>
struct tuple_element<I, sprout::uindex_tuple<Indexes...> >
: public std::tuple_element<I, sprout::integer_seq<sprout::uindex_t, Indexes...> >
{};
2013-01-25 06:14:29 +00:00
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP