#ifndef SPROUT_UTILITY_PAIR_PAIR_HPP #define SPROUT_UTILITY_PAIR_PAIR_HPP #include #include #include #include #include #include #include #include namespace sprout { // Copyright (C) 2011 RiSK (sscrisk) // // 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 ) : first(sprout::tuples::get(first_args)...) , second(sprout::tuples::get(second_args)...) {} public: pair(pair const&) = default; pair(pair&&) = default; SPROUT_CONSTEXPR pair() : first() , second() {} SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y) : first(x) , second(y) {} template SPROUT_CONSTEXPR pair(U&& x, V&& y) : first(sprout::forward(x)) , second(sprout::forward(y)) {} template SPROUT_CONSTEXPR pair(sprout::pair const& p) : first(p.first) , second(p.second) {} template SPROUT_CONSTEXPR pair(sprout::pair&& p) : first(sprout::forward(p.first)) , second(sprout::forward(p.second)) {} #if SPROUT_USE_DELEGATING_CONSTRUCTORS template SPROUT_CONSTEXPR pair( sprout::tuples::tuple first_args, sprout::tuples::tuple second_args ) : pair( first_args, second_args, sprout::index_range<0, sizeof...(Args1)>::make(), sprout::index_range<0, sizeof...(Args2)>::make() ) {} #else // #if SPROUT_USE_DELEGATING_CONSTRUCTORS template SPROUT_CONSTEXPR pair( sprout::tuples::tuple first_args, sprout::tuples::tuple second_args ); #endif // #if SPROUT_USE_DELEGATING_CONSTRUCTORS pair& operator=(pair const& p) = default; template pair& operator=(sprout::pair const& p) { first = p.first; second = p.second; return *this; } pair& operator=(pair&& p) SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) { first = sprout::forward(p.first); second = std::forward(p.second); return *this; } template pair& operator=(sprout::pair&& p) { first = std::forward(p.first); second = std::forward(p.second); return *this; } void swap(pair& p) SPROUT_NOEXCEPT_EXPR( SPROUT_NOEXCEPT_EXPR(swap(first, p.first)) && SPROUT_NOEXCEPT_EXPR(swap(second, p.second)) ) { sprout::swap(first, p.first); sprout::swap(second, p.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_HPP