home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-bin.lha / lib / g++-include / pair.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  1KB  |  47 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Permission to use, copy, modify, distribute and sell this software
  7.  * and its documentation for any purpose is hereby granted without fee,
  8.  * provided that the above copyright notice appear in all copies and
  9.  * that both that copyright notice and this permission notice appear
  10.  * in supporting documentation.  Hewlett-Packard Company makes no
  11.  * representations about the suitability of this software for any
  12.  * purpose.  It is provided "as is" without express or implied warranty.
  13.  *
  14.  */
  15.  
  16. #ifndef PAIR_H
  17. #define PAIR_H
  18.  
  19. #ifndef __GNUG__
  20. #include <bool.h>
  21. #endif
  22.  
  23. template <class T1, class T2>
  24. struct pair {
  25.     T1 first;
  26.     T2 second;
  27.     pair() {}
  28.     pair(const T1& a, const T2& b) : first(a), second(b) {}
  29. };
  30.  
  31. template <class T1, class T2>
  32. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  33.     return x.first == y.first && x.second == y.second; 
  34. }
  35.  
  36. template <class T1, class T2>
  37. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  38.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  39. }
  40.  
  41. template <class T1, class T2>
  42. inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
  43.     return pair<T1, T2>(x, y);
  44. }
  45.  
  46. #endif
  47.