2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2013-01-25 06:14:29 +00:00
|
|
|
#ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP
|
|
|
|
#define SPROUT_INDEX_TUPLE_TUPLE_HPP
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2013-05-10 10:52:39 +00:00
|
|
|
#include <sprout/index_tuple/integer_sequence.hpp>
|
2013-01-25 06:14:29 +00:00
|
|
|
#include <sprout/index_tuple/index_tuple.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/utility/pack.hpp>
|
2013-11-22 12:11:08 +00:00
|
|
|
#include <sprout/type_traits/integral_constant.hpp>
|
2013-01-25 06:14:29 +00:00
|
|
|
|
|
|
|
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>
|
2013-05-10 10:52:39 +00:00
|
|
|
struct tuple_size<sprout::integer_sequence<T, Is...> >
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<std::size_t, sizeof...(Is)>
|
2013-03-31 04:39:26 +00:00
|
|
|
{};
|
|
|
|
//
|
|
|
|
// tuple_element
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename T, T... Is>
|
2014-05-28 15:25:37 +00:00
|
|
|
struct tuple_element<I, sprout::integer_sequence<T, Is...> >
|
|
|
|
: public sprout::pack_element_c<I, T, Is...>
|
|
|
|
{};
|
2013-03-31 04:39:26 +00:00
|
|
|
|
2014-03-07 10:49:30 +00:00
|
|
|
#if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES))
|
2013-01-25 06:14:29 +00:00
|
|
|
//
|
|
|
|
// tuple_size
|
|
|
|
//
|
|
|
|
template<sprout::index_t... Indexes>
|
|
|
|
struct tuple_size<sprout::index_tuple<Indexes...> >
|
2013-05-10 10:52:39 +00:00
|
|
|
: public std::tuple_size<sprout::integer_sequence<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...> >
|
2013-05-10 10:52:39 +00:00
|
|
|
: public std::tuple_element<I, sprout::integer_sequence<sprout::index_t, Indexes...> >
|
2013-03-31 04:39:26 +00:00
|
|
|
{};
|
|
|
|
|
|
|
|
//
|
|
|
|
// tuple_size
|
|
|
|
//
|
|
|
|
template<sprout::uindex_t... Indexes>
|
|
|
|
struct tuple_size<sprout::uindex_tuple<Indexes...> >
|
2013-05-10 10:52:39 +00:00
|
|
|
: public std::tuple_size<sprout::integer_sequence<sprout::uindex_t, Indexes...> >
|
2013-03-31 04:39:26 +00:00
|
|
|
{};
|
|
|
|
//
|
|
|
|
// tuple_element
|
|
|
|
//
|
|
|
|
template<std::size_t I, sprout::uindex_t... Indexes>
|
|
|
|
struct tuple_element<I, sprout::uindex_tuple<Indexes...> >
|
2013-05-10 10:52:39 +00:00
|
|
|
: public std::tuple_element<I, sprout::integer_sequence<sprout::uindex_t, Indexes...> >
|
2013-03-31 04:39:26 +00:00
|
|
|
{};
|
2014-03-07 10:49:30 +00:00
|
|
|
#endif // #if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES))
|
2013-05-10 12:53:53 +00:00
|
|
|
|
2013-01-25 06:14:29 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
# pragma clang diagnostic pop
|
|
|
|
#endif
|
|
|
|
} // namespace std
|
|
|
|
|
2013-04-06 04:06:51 +00:00
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// tuple_get
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename T, T... Is>
|
2013-05-10 10:52:39 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::tuple_element<I, sprout::integer_sequence<T, Is...> >::type
|
|
|
|
tuple_get(sprout::integer_sequence<T, Is...>) SPROUT_NOEXCEPT {
|
2013-04-06 04:06:51 +00:00
|
|
|
static_assert(I < sizeof...(Is), "tuple_get: index out of range");
|
2013-05-10 10:52:39 +00:00
|
|
|
typedef typename std::tuple_element<I, sprout::integer_sequence<T, Is...> >::type type;
|
2013-04-06 04:06:51 +00:00
|
|
|
return type();
|
|
|
|
}
|
|
|
|
|
2014-03-07 10:49:30 +00:00
|
|
|
#if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES))
|
2013-04-06 04:06:51 +00:00
|
|
|
//
|
|
|
|
// tuple_get
|
|
|
|
//
|
|
|
|
template<std::size_t I, sprout::index_t... Indexes>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::tuple_element<I, sprout::index_tuple<Indexes...> >::type
|
|
|
|
tuple_get(sprout::index_tuple<Indexes...>) SPROUT_NOEXCEPT {
|
|
|
|
static_assert(I < sizeof...(Indexes), "tuple_get: index out of range");
|
|
|
|
typedef typename std::tuple_element<I, sprout::index_tuple<Indexes...> >::type type;
|
|
|
|
return type();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// tuple_get
|
|
|
|
//
|
|
|
|
template<std::size_t I, sprout::uindex_t... Indexes>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::tuple_element<I, sprout::uindex_tuple<Indexes...> >::type
|
|
|
|
tuple_get(sprout::uindex_tuple<Indexes...>) SPROUT_NOEXCEPT {
|
|
|
|
static_assert(I < sizeof...(Indexes), "tuple_get: index out of range");
|
|
|
|
typedef typename std::tuple_element<I, sprout::uindex_tuple<Indexes...> >::type type;
|
|
|
|
return type();
|
|
|
|
}
|
2014-03-07 10:49:30 +00:00
|
|
|
#endif // #if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES))
|
2013-04-06 04:06:51 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
2013-01-25 06:14:29 +00:00
|
|
|
#endif // #ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP
|