/*! @file Adapts `std::pair` for use with Hana. @copyright Louis Dionne 2013-2016 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_EXT_STD_PAIR_HPP #define BOOST_HANA_EXT_STD_PAIR_HPP #include #include #include #include #include #include #ifdef BOOST_HANA_DOXYGEN_INVOKED namespace std { //! @ingroup group-ext-std //! Adaptation of `std::pair` for Hana. //! //! //! Modeled concepts //! ---------------- //! A `std::pair` models exactly the same concepts as a `hana::pair`. //! Please refer to the documentation of `hana::pair` for details. //! //! @include example/ext/std/pair.cpp template struct pair { }; } #endif BOOST_HANA_NAMESPACE_BEGIN namespace ext { namespace std { struct pair_tag; }} template struct tag_of> { using type = ext::std::pair_tag; }; ////////////////////////////////////////////////////////////////////////// // Product ////////////////////////////////////////////////////////////////////////// template <> struct make_impl { template static constexpr decltype(auto) apply(X&& x, Y&& y) { return std::make_pair(static_cast(x), static_cast(y)); } }; template <> struct first_impl { template static constexpr T const& apply(std::pair const& p) { return p.first; } template static constexpr T& apply(std::pair& p) { return p.first; } template static constexpr T&& apply(std::pair&& p) { return static_cast(p.first); } }; template <> struct second_impl { template static constexpr U const& apply(std::pair const& p) { return p.second; } template static constexpr U& apply(std::pair& p) { return p.second; } template static constexpr U&& apply(std::pair&& p) { return static_cast(p.second); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_EXT_STD_PAIR_HPP