#ifndef SPROUT_UTILITY_PAIR_TUPLE_HPP #define SPROUT_UTILITY_PAIR_TUPLE_HPP #include #include #include #include #include namespace sprout { namespace tuples { namespace detail { template struct tuple_element_impl; template struct tuple_element_impl<0, sprout::pair > { public: typedef T1 type; }; template struct tuple_element_impl<1, sprout::pair > { public: typedef T2 type; }; template struct get_impl; template struct get_impl<0, sprout::pair > { public: SPROUT_CONSTEXPR T1& operator()(sprout::pair& t) const { return t.first; } SPROUT_CONSTEXPR T1 const& operator()(sprout::pair const& t) const { return t.first; } }; template struct get_impl<1, sprout::pair > { public: SPROUT_CONSTEXPR T2& operator()(sprout::pair& t) const { return t.second; } SPROUT_CONSTEXPR T2 const& operator()(sprout::pair const& t) const { return t.second; } }; } // namespace detail } // namespace tuples } // namespace sprout namespace std { #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wmismatched-tags" #endif // // tuple_size // template struct tuple_size > : public std::integral_constant {}; // // tuple_element // template struct tuple_element > : public sprout::tuples::detail::tuple_element_impl > {}; #if defined(__clang__) # pragma clang diagnostic pop #endif } // namespace std namespace sprout { // // tuple_get // template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type& tuple_get(sprout::pair& t) SPROUT_NOEXCEPT { static_assert(I < 2, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type const& tuple_get(sprout::pair const& t) SPROUT_NOEXCEPT { static_assert(I < 2, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type&& tuple_get(sprout::pair&& t) SPROUT_NOEXCEPT { return sprout::move(sprout::tuples::get(t)); } } // namespace sprout #endif // #ifndef SPROUT_UTILITY_PAIR_TUPLE_HPP