/*============================================================================= Copyright (c) 2011-2013 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_UTILITY_PAIR_PAIR_DECL_HPP #define SPROUT_UTILITY_PAIR_PAIR_DECL_HPP #include #include #include #include #include #include #include #include namespace sprout { // // pair // template struct pair { public: typedef T1 first_type; typedef T2 second_type; public: T1 first; T2 second; private: template SPROUT_CONSTEXPR pair( sprout::tuples::tuple first_args, sprout::tuples::tuple second_args, sprout::index_tuple, sprout::index_tuple ); public: SPROUT_CONSTEXPR pair() : first() , second() {} SPROUT_CONSTEXPR pair(pair const&) = default; SPROUT_CONSTEXPR pair(pair&&) = default; SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y) : first(x) , second(y) {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair(U&& x, V&& y) : first(sprout::forward(x)) , second(sprout::forward(y)) {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair(sprout::pair const& other) : first(other.first) , second(other.second) {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair(sprout::pair&& other) : first(sprout::forward(other.first)) , second(sprout::forward(other.second)) {} template< typename... Args1, typename... Args2, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair( std::piecewise_construct_t, sprout::tuples::tuple first_args, sprout::tuples::tuple second_args ); template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair(sprout::tuples::tuple const& other); template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > SPROUT_CONSTEXPR pair(sprout::tuples::tuple&& other); pair& operator=(pair const& rhs) = default; pair& operator=(pair&& rhs) SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) { first = sprout::forward(rhs.first); second = sprout::forward(rhs.second); return *this; } template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > pair& operator=(sprout::pair const& rhs) { first = rhs.first; second = rhs.second; return *this; } template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > pair& operator=(sprout::pair&& rhs) { first = sprout::forward(rhs.first); second = sprout::forward(rhs.second); return *this; } template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > pair& operator=(sprout::tuples::tuple const& rhs); template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > pair& operator=(sprout::tuples::tuple&& rhs); void swap(pair& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) { sprout::swap(first, other.first); sprout::swap(second, other.second); } }; // // swap // template inline void swap(sprout::pair& lhs, sprout::pair& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { lhs.swap(rhs); } } // namespace sprout #endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_DECL_HPP