2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2017-07-29 05:20:01 +00:00
|
|
|
Copyright (c) 2011-2017 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)
|
|
|
|
=============================================================================*/
|
2011-10-31 11:10:07 +00:00
|
|
|
#ifndef SPROUT_TUPLE_SSCRISK_CEL_UTILITY_HPP
|
|
|
|
#define SPROUT_TUPLE_SSCRISK_CEL_UTILITY_HPP
|
|
|
|
|
2012-05-31 13:28:58 +00:00
|
|
|
#include <sscrisk/cel/utility.hpp>
|
2011-10-31 11:10:07 +00:00
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2012-05-31 13:28:58 +00:00
|
|
|
#include <sprout/utility/move.hpp>
|
2012-09-29 09:41:13 +00:00
|
|
|
#include <sprout/tuple/tuple.hpp>
|
2013-11-22 12:11:08 +00:00
|
|
|
#include <sprout/type_traits/integral_constant.hpp>
|
2014-05-28 15:25:37 +00:00
|
|
|
#include <sprout/type_traits/identity.hpp>
|
|
|
|
#include <sprout/detail/nil_base.hpp>
|
2011-10-31 11:10:07 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace tuples {
|
|
|
|
//
|
|
|
|
// tuple_size
|
|
|
|
//
|
|
|
|
template<typename T1, typename T2>
|
2012-05-19 09:46:38 +00:00
|
|
|
struct tuple_size<sscrisk::cel::pair<T1, T2> >
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<std::size_t, 2>
|
2011-10-31 11:10:07 +00:00
|
|
|
{};
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template<std::size_t I, typename T>
|
2012-05-19 09:46:38 +00:00
|
|
|
struct tuple_element_impl;
|
2014-05-28 15:25:37 +00:00
|
|
|
template<std::size_t I, typename T1, typename T2>
|
|
|
|
struct tuple_element_impl<I, sscrisk::cel::pair<T1, T2> >
|
|
|
|
: public sprout::detail::nil_base
|
|
|
|
{};
|
2011-10-31 11:10:07 +00:00
|
|
|
template<typename T1, typename T2>
|
2014-05-28 15:25:37 +00:00
|
|
|
struct tuple_element_impl<0, sscrisk::cel::pair<T1, T2> >
|
|
|
|
: public sprout::identity<T1>
|
|
|
|
{};
|
2011-10-31 11:10:07 +00:00
|
|
|
template<typename T1, typename T2>
|
2014-05-28 15:25:37 +00:00
|
|
|
struct tuple_element_impl<1, sscrisk::cel::pair<T1, T2> >
|
|
|
|
: public sprout::identity<T2>
|
|
|
|
{};
|
2011-10-31 11:10:07 +00:00
|
|
|
} // namespace detail
|
2012-09-29 09:41:13 +00:00
|
|
|
//
|
|
|
|
// tuple_element
|
|
|
|
//
|
2011-10-31 11:10:07 +00:00
|
|
|
template<std::size_t I, typename T1, typename T2>
|
2012-05-19 09:46:38 +00:00
|
|
|
struct tuple_element<I, sscrisk::cel::pair<T1, T2> >
|
2011-10-31 11:10:07 +00:00
|
|
|
: public sprout::tuples::detail::tuple_element_impl<I, sscrisk::cel::pair<T1, T2> >
|
|
|
|
{};
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template<std::size_t I, typename T>
|
|
|
|
struct get_impl;
|
|
|
|
template<typename T1, typename T2>
|
|
|
|
struct get_impl<0, sscrisk::cel::pair<T1, T2> > {
|
|
|
|
public:
|
2012-05-31 13:28:58 +00:00
|
|
|
SPROUT_CONSTEXPR T1& operator()(sscrisk::cel::pair<T1, T2>& t) const {
|
2011-10-31 11:10:07 +00:00
|
|
|
return t.first;
|
|
|
|
}
|
2012-05-31 13:28:58 +00:00
|
|
|
SPROUT_CONSTEXPR T1 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
|
2011-10-31 11:10:07 +00:00
|
|
|
return t.first;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<typename T1, typename T2>
|
|
|
|
struct get_impl<1, sscrisk::cel::pair<T1, T2> > {
|
|
|
|
public:
|
2012-05-31 13:28:58 +00:00
|
|
|
SPROUT_CONSTEXPR T2& operator()(sscrisk::cel::pair<T1, T2>& t) const {
|
2011-10-31 11:10:07 +00:00
|
|
|
return t.second;
|
|
|
|
}
|
2012-05-31 13:28:58 +00:00
|
|
|
SPROUT_CONSTEXPR T2 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
|
2011-10-31 11:10:07 +00:00
|
|
|
return t.second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace detail
|
2012-09-29 09:41:13 +00:00
|
|
|
} // namespace tuples
|
|
|
|
} // namespace sprout
|
|
|
|
|
2013-04-22 04:04:27 +00:00
|
|
|
namespace sprout {
|
|
|
|
namespace tuples {
|
|
|
|
//
|
|
|
|
// tuple_access_traits
|
|
|
|
//
|
|
|
|
template<typename T1, typename T2>
|
|
|
|
struct tuple_access_traits<sscrisk::cel::pair<T1, T2> > {
|
|
|
|
public:
|
|
|
|
template<std::size_t I>
|
|
|
|
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&
|
|
|
|
tuple_get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
|
|
|
static_assert(I < 2, "tuple_get: index out of range");
|
|
|
|
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
|
|
|
}
|
|
|
|
template<std::size_t I>
|
|
|
|
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const&
|
|
|
|
tuple_get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
|
|
|
static_assert(I < 2, "tuple_get: index out of range");
|
|
|
|
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
|
|
|
}
|
|
|
|
template<std::size_t I>
|
|
|
|
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&&
|
|
|
|
tuple_get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
|
|
|
return sprout::move(tuple_get<I>(t));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace tuples
|
|
|
|
} // namespace sprout
|
2011-10-31 11:10:07 +00:00
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_UTILITY_HPP
|