_pair.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996,1997
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999 
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted 
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 
00027 /* NOTE: This is an internal header file, included by other STL headers.
00028  *   You should not attempt to use it directly.
00029  */
00030 
00031 #ifndef _STLP_INTERNAL_PAIR_H
00032 #define _STLP_INTERNAL_PAIR_H
00033 
00034 _STLP_BEGIN_NAMESPACE
00035 
00036 template <class _T1, class _T2>
00037 struct pair {
00038   typedef _T1 first_type;
00039   typedef _T2 second_type;
00040 
00041   _T1 first;
00042   _T2 second;
00043 # if defined (_STLP_CONST_CONSTRUCTOR_BUG)
00044   pair() {}
00045 # else
00046   pair() : first(_T1()), second(_T2()) {}
00047 # endif
00048   pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
00049 
00050 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
00051   template <class _U1, class _U2>
00052   pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
00053 
00054   pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
00055 #endif
00056   __TRIVIAL_DESTRUCTOR(pair)
00057 };
00058 
00059 template <class _T1, class _T2>
00060 inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00061 { 
00062   return __x.first == __y.first && __x.second == __y.second; 
00063 }
00064 
00065 template <class _T1, class _T2>
00066 inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00067 { 
00068   return __x.first < __y.first || 
00069          (!(__y.first < __x.first) && __x.second < __y.second); 
00070 }
00071 
00072 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
00073 
00074 template <class _T1, class _T2>
00075 inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
00076   return !(__x == __y);
00077 }
00078 
00079 template <class _T1, class _T2>
00080 inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
00081   return __y < __x;
00082 }
00083 
00084 template <class _T1, class _T2>
00085 inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
00086   return !(__y < __x);
00087 }
00088 
00089 template <class _T1, class _T2>
00090 inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
00091   return !(__x < __y);
00092 }
00093 
00094 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
00095 
00096 
00097 #if defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && ! defined (_STLP_NO_EXTENSIONS) && ! defined (__BORLANDC__)
00098 template <class _T1, class _T2, int _Sz>
00099 inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
00100                                        _T2 const (&__y)[_Sz])
00101 {
00102   return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y));
00103 }
00104 
00105 template <class _T1, class _T2, int _Sz>
00106 inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
00107                                        _T2 const& __y)
00108 {
00109   return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y);
00110 }
00111 
00112 template <class _T1, class _T2, int _Sz1, int _Sz2>
00113 inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
00114                                               _T2 const (&__y)[_Sz2])
00115 {
00116   return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
00117                                       static_cast<_T2 const*>(__y));
00118 }
00119 #endif
00120 
00121 template <class _T1, class _T2>
00122 inline pair<_T1, _T2> _STLP_CALL make_pair(const _T1& __x, const _T2& __y)
00123 {
00124   return pair<_T1, _T2>(__x, __y);
00125 }
00126 
00127 
00128 _STLP_END_NAMESPACE
00129 
00130 # if defined (_STLP_USE_NAMESPACES) || ! defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) 
00131 _STLP_BEGIN_RELOPS_NAMESPACE
00132 
00133 template <class _Tp>
00134 inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) {
00135   return !(__x == __y);
00136 }
00137 
00138 template <class _Tp>
00139 inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) {
00140   return __y < __x;
00141 }
00142 
00143 template <class _Tp>
00144 inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) {
00145   return !(__y < __x);
00146 }
00147 
00148 template <class _Tp>
00149 inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y) {
00150   return !(__x < __y);
00151 }
00152 
00153 _STLP_END_RELOPS_NAMESPACE
00154 
00155 # endif
00156 
00157 #endif /* _STLP_INTERNAL_PAIR_H */
00158 
00159 // Local Variables:
00160 // mode:C++
00161 // End:

Generated on Mon Jun 5 10:20:46 2006 for Intelligence.kdevelop by  doxygen 1.4.6