// This file is part of the uSTL library, an STL implementation. // // Copyright (c) 2005 by Mike Sharov // This file is free software, distributed under the MIT License. #ifndef UPAIR_H_7DC08F1B7FECF8AE6856D84C3B617A75 #define UPAIR_H_7DC08F1B7FECF8AE6856D84C3B617A75 #include "utypes.h" namespace ustl { /// \class pair upair.h ustl.h /// \ingroup AssociativeContainers /// /// \brief Container for two values. /// template class pair { public: typedef T1 first_type; typedef T2 second_type; public: /// Default constructor. inline pair (void) : first (T1()), second (T2()) {} /// Initializes members with \p a, and \p b. inline pair (const T1& a, const T2& b) : first (a), second (b) {} inline pair& operator= (const pair& p2) { first = p2.first; second = p2.second; return (*this); } template inline pair& operator= (const pair& p2) { first = p2.first; second = p2.second; return (*this); } public: first_type first; second_type second; }; /// Compares both values of \p p1 to those of \p p2. template inline bool operator== (const pair& p1, const pair& p2) { return (p1.first == p2.first && p1.second == p2.second); } /// Compares both values of \p p1 to those of \p p2. template bool operator< (const pair& p1, const pair& p2) { return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second)); } /// Returns a pair object with (a,b) template inline pair make_pair (const T1& a, const T2& b) { return (pair (a, b)); } } // namespace ustl #endif