home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qpair.h < prev    next >
C/C++ Source or Header  |  2001-08-04  |  2KB  |  81 lines

  1. /****************************************************************************
  2. **
  3. ** Definition of QPair class
  4. **
  5. **
  6. ** Copyright (C) 1992-2001 Trolltech AS.  All rights reserved.
  7. **
  8. ** This file is part of the tools module of the Qt GUI Toolkit.
  9. **
  10. ** This file may be distributed under the terms of the Q Public License
  11. ** as defined by Trolltech AS of Norway and appearing in the file
  12. ** LICENSE.QPL included in the packaging of this file.
  13. **
  14. ** This file may be distributed and/or modified under the terms of the
  15. ** GNU General Public License version 2 as published by the Free Software
  16. ** Foundation and appearing in the file LICENSE.GPL included in the
  17. ** packaging of this file.
  18. **
  19. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  20. ** licenses may use this file in accordance with the Qt Commercial License
  21. ** Agreement provided with the Software.
  22. **
  23. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  24. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25. **
  26. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  27. **   information about Qt Commercial License Agreements.
  28. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  29. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  30. **
  31. ** Contact info@trolltech.com if any conditions of this licensing are
  32. ** not clear to you.
  33. **
  34. **********************************************************************/
  35.  
  36. #ifndef QPAIR_H
  37. #define QPAIR_H
  38.  
  39. #ifndef QT_H
  40. #endif // QT_H
  41.  
  42. template <class T1, class T2>
  43. struct QPair
  44. {
  45.     typedef T1 first_type;
  46.     typedef T2 second_type;
  47.  
  48.     QPair()
  49.     : first( T1() ), second( T2() )
  50.     {}
  51.     QPair( const T1& t1, const T2& t2 )
  52.     : first( t1 ), second( t2 )
  53.     {}
  54.  
  55.     T1 first;
  56.     T2 second;
  57. };
  58.  
  59. template <class T1, class T2>
  60. inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
  61. {
  62.     return x.first == y.first && x.second == y.second;
  63. }
  64.  
  65. template <class T1, class T2>
  66. inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
  67. {
  68.     // x < y is TRUE if:
  69.     // x.first is less than y.first,
  70.     // or if x.second is less that y.second and x.first is the same as y.first
  71.     return x.first < y.first ||    ( !( y.first < x.first ) && x.second < y.second );
  72. }
  73.  
  74. template <class T1, class T2>
  75. inline QPair<T1, T2> qMakePair( const T1& x, const T2& y )
  76. {
  77.     return QPair<T1, T2>( x, y );
  78. }
  79.  
  80. #endif
  81.