home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _pair.h < prev    next >
C/C++ Source or Header  |  2001-09-29  |  4KB  |  162 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Copyright (c) 1996,1997
  7.  * Silicon Graphics Computer Systems, Inc.
  8.  *
  9.  * Copyright (c) 1997
  10.  * Moscow Center for SPARC Technology
  11.  *
  12.  * Copyright (c) 1999 
  13.  * Boris Fomitchev
  14.  *
  15.  * This material is provided "as is", with absolutely no warranty expressed
  16.  * or implied. Any use is at your own risk.
  17.  *
  18.  * Permission to use or copy this software for any purpose is hereby granted 
  19.  * without fee, provided the above notices are retained on all copies.
  20.  * Permission to modify the code and to distribute modified code is granted,
  21.  * provided the above notices are retained, and a notice that the code was
  22.  * modified is included with the above copyright notice.
  23.  *
  24.  */
  25.  
  26.  
  27. /* NOTE: This is an internal header file, included by other STL headers.
  28.  *   You should not attempt to use it directly.
  29.  */
  30.  
  31. #ifndef _STLP_INTERNAL_PAIR_H
  32. #define _STLP_INTERNAL_PAIR_H
  33.  
  34. _STLP_BEGIN_NAMESPACE
  35.  
  36. template <class _T1, class _T2>
  37. struct pair {
  38.   typedef _T1 first_type;
  39.   typedef _T2 second_type;
  40.  
  41.   _T1 first;
  42.   _T2 second;
  43. # if defined (_STLP_CONST_CONSTRUCTOR_BUG)
  44.   pair() {}
  45. # else
  46.   pair() : first(_T1()), second(_T2()) {}
  47. # endif
  48.   pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
  49.  
  50. #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
  51.   template <class _U1, class _U2>
  52.   pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
  53.  
  54.   pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
  55. #endif
  56.   __TRIVIAL_DESTRUCTOR(pair)
  57. };
  58.  
  59. template <class _T1, class _T2>
  60. inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
  61.   return __x.first == __y.first && __x.second == __y.second; 
  62. }
  63.  
  64. template <class _T1, class _T2>
  65. inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
  66.   return __x.first < __y.first || 
  67.          (!(__y.first < __x.first) && __x.second < __y.second); 
  68. }
  69.  
  70. #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
  71.  
  72. template <class _T1, class _T2>
  73. inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
  74.   return !(__x == __y);
  75. }
  76.  
  77. template <class _T1, class _T2>
  78. inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
  79.   return __y < __x;
  80. }
  81.  
  82. template <class _T1, class _T2>
  83. inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
  84.   return !(__y < __x);
  85. }
  86.  
  87. template <class _T1, class _T2>
  88. inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
  89.   return !(__x < __y);
  90. }
  91.  
  92. #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
  93.  
  94.  
  95. #if defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && ! defined (_STLP_NO_EXTENSIONS) && ! defined (__BORLANDC__)
  96. template <class _T1, class _T2, int _Sz>
  97. inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
  98.                                        _T2 const (&__y)[_Sz])
  99. {
  100.   return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y));
  101. }
  102.  
  103. template <class _T1, class _T2, int _Sz>
  104. inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
  105.                                        _T2 const& __y)
  106. {
  107.   return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y);
  108. }
  109.  
  110. template <class _T1, class _T2, int _Sz1, int _Sz2>
  111. inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
  112.                                               _T2 const (&__y)[_Sz2])
  113. {
  114.   return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
  115.                                       static_cast<_T2 const*>(__y));
  116. }
  117. #endif
  118.  
  119. template <class _T1, class _T2>
  120. inline pair<_T1, _T2> _STLP_CALL make_pair(const _T1& __x, const _T2& __y)
  121. {
  122.   return pair<_T1, _T2>(__x, __y);
  123. }
  124.  
  125.  
  126. _STLP_END_NAMESPACE
  127.  
  128. # if defined (_STLP_USE_NAMESPACES) || ! defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) 
  129. _STLP_BEGIN_RELOPS_NAMESPACE
  130.  
  131. template <class _Tp>
  132. inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) {
  133.   return !(__x == __y);
  134. }
  135.  
  136. template <class _Tp>
  137. inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) {
  138.   return __y < __x;
  139. }
  140.  
  141. template <class _Tp>
  142. inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) {
  143.   return !(__y < __x);
  144. }
  145.  
  146. template <class _Tp>
  147. inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y) {
  148.   return !(__x < __y);
  149. }
  150.  
  151. _STLP_END_RELOPS_NAMESPACE
  152.  
  153. # endif
  154.  
  155. #endif /* _STLP_INTERNAL_PAIR_H */
  156.  
  157. // Local Variables:
  158. // mode:C++
  159. // End:
  160.