2012-06-22 10:14:21 +00:00
|
|
|
#ifndef SPROUT_PIT_TUPLE_HPP
|
|
|
|
#define SPROUT_PIT_TUPLE_HPP
|
2011-10-31 11:30:08 +00:00
|
|
|
|
|
|
|
#include <cstddef>
|
2012-06-22 10:14:21 +00:00
|
|
|
#include <tuple>
|
2011-10-31 11:30:08 +00:00
|
|
|
#include <type_traits>
|
2012-06-22 10:14:21 +00:00
|
|
|
#include <sprout/pit/pit.hpp>
|
2012-05-31 13:28:58 +00:00
|
|
|
#include <sprout/utility/move.hpp>
|
2011-10-31 11:30:08 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace tuples {
|
|
|
|
//
|
|
|
|
// get
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename Container>
|
2012-05-31 13:28:58 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type&
|
|
|
|
get(sprout::pit<Container>& t) SPROUT_NOEXCEPT {
|
2012-03-31 07:24:13 +00:00
|
|
|
static_assert(I < sprout::container_traits<sprout::pit<Container> >::static_size, "get: index out of range");
|
2011-10-31 11:30:08 +00:00
|
|
|
return t[I];
|
|
|
|
}
|
|
|
|
template<std::size_t I, typename Container>
|
2012-05-31 13:28:58 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type const&
|
|
|
|
get(sprout::pit<Container> const& t) SPROUT_NOEXCEPT {
|
2012-03-31 07:24:13 +00:00
|
|
|
static_assert(I < sprout::container_traits<sprout::pit<Container> >::static_size, "get: index out of range");
|
2011-10-31 11:30:08 +00:00
|
|
|
return t[I];
|
|
|
|
}
|
|
|
|
template<std::size_t I, typename Container>
|
2012-05-31 13:28:58 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type&&
|
|
|
|
get(sprout::pit<Container>&& t)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::move(sprout::tuples::get<I>(t))))
|
2011-10-31 11:30:08 +00:00
|
|
|
{
|
2012-05-31 13:28:58 +00:00
|
|
|
return sprout::move(sprout::tuples::get<I>(t));
|
2011-10-31 11:30:08 +00:00
|
|
|
}
|
|
|
|
} // namespace tuples
|
|
|
|
|
|
|
|
using sprout::tuples::get;
|
|
|
|
} // namespace sprout
|
|
|
|
|
2012-06-22 10:14:21 +00:00
|
|
|
namespace std {
|
|
|
|
//
|
|
|
|
// tuple_size
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct tuple_size<sprout::pit<Container> >
|
|
|
|
: public std::tuple_size<Container>
|
|
|
|
{};
|
|
|
|
|
|
|
|
//
|
|
|
|
// tuple_element
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename Container>
|
|
|
|
struct tuple_element<I, sprout::pit<Container> >
|
|
|
|
: public std::tuple_element<I, Container>
|
|
|
|
{};
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_PIT_TUPLE_HPP
|