]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c++/stl/stl/_pair.h
Add STLport 5.1.4
[polintos/scott/priv.git] / include / c++ / stl / stl / _pair.h
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 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
35 #  include <stl/type_traits.h>
36 #endif
37
38 #ifndef _STLP_MOVE_CONSTRUCT_FWK_H
39 #  include <stl/_move_construct_fwk.h>
40 #endif
41
42 _STLP_BEGIN_NAMESPACE
43
44 template <class _T1, class _T2>
45 struct pair {
46   typedef _T1 first_type;
47   typedef _T2 second_type;
48
49   _T1 first;
50   _T2 second;
51 #if defined (_STLP_CONST_CONSTRUCTOR_BUG)
52   pair() {}
53 #else
54   pair() : first(_T1()), second(_T2()) {}
55 #endif
56   pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
57
58 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
59   template <class _U1, class _U2>
60   pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
61
62   pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
63 #endif
64
65   pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)),
66                                              second(_STLP_PRIV _AsMoveSource(src.get().second))
67   {}
68
69   __TRIVIAL_DESTRUCTOR(pair)
70 };
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.first == __y.first && __x.second == __y.second; }
75
76 template <class _T1, class _T2>
77 inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
78   return __x.first < __y.first ||
79          (!(__y.first < __x.first) && __x.second < __y.second);
80 }
81
82 #if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
83 template <class _T1, class _T2>
84 inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
85 { return !(__x == __y); }
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 __y < __x; }
90
91 template <class _T1, class _T2>
92 inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
93 { return !(__y < __x); }
94
95 template <class _T1, class _T2>
96 inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
97 { return !(__x < __y); }
98 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
99
100 #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
101 template <class _T1, class _T2, int _Sz>
102 inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
103                                        _T2 const (&__y)[_Sz])
104 { return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); }
105
106 template <class _T1, class _T2, int _Sz>
107 inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
108                                        _T2 const& __y)
109 { return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); }
110
111 template <class _T1, class _T2, int _Sz1, int _Sz2>
112 inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
113                                               _T2 const (&__y)[_Sz2]) {
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(_T1 __x, _T2 __y)
121 { return pair<_T1, _T2>(__x, __y); }
122
123 _STLP_END_NAMESPACE
124
125 #if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
126 _STLP_BEGIN_RELOPS_NAMESPACE
127
128 template <class _Tp>
129 inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y)
130 { return !(__x == __y); }
131
132 template <class _Tp>
133 inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y)
134 { return __y < __x; }
135
136 template <class _Tp>
137 inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y)
138 { return !(__y < __x); }
139
140 template <class _Tp>
141 inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y)
142 { return !(__x < __y); }
143
144 _STLP_END_RELOPS_NAMESPACE
145 #endif
146
147 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
148 _STLP_BEGIN_NAMESPACE
149
150 template <class _T1, class _T2>
151 struct __type_traits<pair<_T1, _T2> > {
152   typedef __type_traits<_T1> _T1Traits;
153   typedef __type_traits<_T2> _T2Traits;
154   typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor,
155                           typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor;
156   typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor,
157                           typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor;
158   typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator,
159                           typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator;
160   typedef typename _Land2<typename _T1Traits::has_trivial_destructor,
161                           typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor;
162   typedef __false_type is_POD_type;
163
164 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
165   // disable incorrect "dependent type qualifier" error
166   typedef __false_type implemented;
167 #endif
168 };
169
170 template <class _T1, class _T2>
171 struct __move_traits<pair<_T1, _T2> >
172   : _STLP_PRIV __move_traits_help1<_T1, _T2> {};
173
174 _STLP_END_NAMESPACE
175 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
176
177 #endif /* _STLP_INTERNAL_PAIR_H */
178
179 // Local Variables:
180 // mode:C++
181 // End: