//======================================================================= // Copyright Baptiste Wicht 2013-2018. // Distributed under the terms of the MIT License. // (See accompanying file LICENSE or copy at // http://www.opensource.org/licenses/MIT) //======================================================================= #ifndef PAIR_H #define PAIR_H namespace std { /*! * \brief Simply container to hold a pair of element */ template class pair { public: using first_type = T1; ///< The type of the first element using second_type = T2; ///< The type of the second element first_type first; ///< The first element second_type second; ///< The second element //Constructor constexpr pair(const first_type& a, const second_type& b) : first(a), second(b){ //Nothing to init } template constexpr pair(U1&& x, U2&& y) : first(std::forward(x)), second(std::forward(y)){ //Nothing to init } //Copy constructors constexpr pair(const pair&) = default; template constexpr pair(const pair& p) : first(p.first), second(p.second) { //Nothing to init } template pair& operator=(const pair& p){ first = p.first; second = p.second; return *this; } //Move constructors constexpr pair(pair&&) = default; template constexpr pair(pair&& p) : first(std::move(p.first)), second(std::move(p.second)) { //Nothing to init } template pair& operator=(pair&& p){ first = std::forward(p.first); second = std::forward(p.second); return *this; } }; /*! * \brief Helper to construct a pair */ template inline constexpr pair make_pair(T1&& x, T2&& y){ return pair(std::forward(x), std::forward(y)); } } //end of namespace std #endif