/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI 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) =============================================================================*/ #ifndef SPROUT_TUPLE_STD_UTILITY_HPP #define SPROUT_TUPLE_STD_UTILITY_HPP #include #include #include #include #include #include namespace sprout { namespace tuples { namespace detail { template struct get_impl; template struct get_impl<0, std::pair > { public: SPROUT_CONSTEXPR T1& operator()(std::pair& t) const { return t.first; } SPROUT_CONSTEXPR T1 const& operator()(std::pair const& t) const { return t.first; } }; template struct get_impl<1, std::pair > { public: SPROUT_CONSTEXPR T2& operator()(std::pair& t) const { return t.second; } SPROUT_CONSTEXPR T2 const& operator()(std::pair const& t) const { return t.second; } }; } // namespace detail } // namespace tuples } // namespace sprout namespace sprout { namespace tuples { // // tuple_access_traits // template struct tuple_access_traits > { public: template static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type& tuple_get(std::pair& t) SPROUT_NOEXCEPT { static_assert(I < 2, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type const& tuple_get(std::pair const& t) SPROUT_NOEXCEPT { static_assert(I < 2, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type&& tuple_get(std::pair&& t) SPROUT_NOEXCEPT { return sprout::move(tuple_get(t)); } }; } // namespace tuples } // namespace sprout #endif // #ifndef SPROUT_TUPLE_STD_UTILITY_HPP