/*! @file Defines `boost::hana::pair`. @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_PAIR_HPP #define BOOST_HANA_PAIR_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN ////////////////////////////////////////////////////////////////////////// // pair ////////////////////////////////////////////////////////////////////////// //! @cond template struct pair : detail::operators::adl> { template ::type> constexpr pair() : storage_() { } template ::type> constexpr pair(First const& first, Second const& second) : storage_{first, second} { } template ::type> constexpr pair(T&& t, U&& u) : storage_{static_cast(t), static_cast(u)} { } template ::type> constexpr pair(pair const& other) : storage_{hana::get_impl<0>(other.storage_), hana::get_impl<1>(other.storage_)} { } template ::type> constexpr pair(pair&& other) : storage_{static_cast(hana::get_impl<0>(other.storage_)), static_cast(hana::get_impl<1>(other.storage_))} { } template ::type> constexpr pair& operator=(pair const& other) { hana::get_impl<0>(storage_) = hana::get_impl<0>(other.storage_); hana::get_impl<1>(storage_) = hana::get_impl<1>(other.storage_); return *this; } template ::type> constexpr pair& operator=(pair&& other) { hana::get_impl<0>(storage_) = static_cast(hana::get_impl<0>(other.storage_)); hana::get_impl<1>(storage_) = static_cast(hana::get_impl<1>(other.storage_)); return *this; } using hana_tag = pair_tag; basic_tuple storage_; }; //! @endcond ////////////////////////////////////////////////////////////////////////// // Operators ////////////////////////////////////////////////////////////////////////// namespace detail { template <> struct comparable_operators { static constexpr bool value = true; }; template <> struct orderable_operators { static constexpr bool value = true; }; } ////////////////////////////////////////////////////////////////////////// // Product ////////////////////////////////////////////////////////////////////////// template <> struct make_impl { template static constexpr pair< typename detail::decay::type, typename detail::decay::type > apply(F&& f, S&& s) { return {static_cast(f), static_cast(s)}; } }; template <> struct first_impl { template static constexpr decltype(auto) apply(P&& p) { return hana::get_impl<0>(static_cast(p).storage_); } }; template <> struct second_impl { template static constexpr decltype(auto) apply(P&& p) { return hana::get_impl<1>(static_cast(p).storage_); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_PAIR_HPP