00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifndef _STL_PAIR_H
00063 #define _STL_PAIR_H 1
00064
00065 #include <bits/stl_move.h>
00066
00067
00068 _GLIBCXX_BEGIN_NAMESPACE(std)
00069
00070
00071 template<class _T1, class _T2>
00072 struct pair
00073 {
00074 typedef _T1 first_type;
00075 typedef _T2 second_type;
00076
00077 _T1 first;
00078 _T2 second;
00079
00080
00081
00082
00083
00084 pair()
00085 : first(), second() { }
00086
00087
00088 pair(const _T1& __a, const _T2& __b)
00089 : first(__a), second(__b) { }
00090
00091 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00092 template<class _U1, class _U2>
00093 pair(_U1&& __x, _U2&& __y)
00094 : first(std::forward<_U1>(__x)),
00095 second(std::forward<_U2>(__y)) { }
00096
00097 pair(pair&& __p)
00098 : first(std::move(__p.first)),
00099 second(std::move(__p.second)) { }
00100 #endif
00101
00102
00103 template<class _U1, class _U2>
00104 pair(const pair<_U1, _U2>& __p)
00105 : first(__p.first),
00106 second(__p.second) { }
00107
00108 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00109 template<class _U1, class _U2>
00110 pair(pair<_U1, _U2>&& __p)
00111 : first(std::move(__p.first)),
00112 second(std::move(__p.second)) { }
00113
00114
00115 template<class _U1, class _Arg0, class... _Args>
00116 pair(_U1&& __x, _Arg0&& __arg0, _Args&&... __args)
00117 : first(std::forward<_U1>(__x)),
00118 second(std::forward<_Arg0>(__arg0),
00119 std::forward<_Args>(__args)...) { }
00120
00121 pair&
00122 operator=(pair&& __p)
00123 {
00124 first = std::move(__p.first);
00125 second = std::move(__p.second);
00126 return *this;
00127 }
00128
00129 template<class _U1, class _U2>
00130 pair&
00131 operator=(pair<_U1, _U2>&& __p)
00132 {
00133 first = std::move(__p.first);
00134 second = std::move(__p.second);
00135 return *this;
00136 }
00137
00138 void
00139 swap(pair&& __p)
00140 {
00141 using std::swap;
00142 swap(first, __p.first);
00143 swap(second, __p.second);
00144 }
00145 #endif
00146 };
00147
00148
00149 template<class _T1, class _T2>
00150 inline bool
00151 operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00152 { return __x.first == __y.first && __x.second == __y.second; }
00153
00154
00155 template<class _T1, class _T2>
00156 inline bool
00157 operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00158 { return __x.first < __y.first
00159 || (!(__y.first < __x.first) && __x.second < __y.second); }
00160
00161
00162 template<class _T1, class _T2>
00163 inline bool
00164 operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00165 { return !(__x == __y); }
00166
00167
00168 template<class _T1, class _T2>
00169 inline bool
00170 operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00171 { return __y < __x; }
00172
00173
00174 template<class _T1, class _T2>
00175 inline bool
00176 operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00177 { return !(__y < __x); }
00178
00179
00180 template<class _T1, class _T2>
00181 inline bool
00182 operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00183 { return !(__x < __y); }
00184
00185 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00186
00187 template<class _T1, class _T2>
00188 inline void
00189 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
00190 { __x.swap(__y); }
00191
00192 template<class _T1, class _T2>
00193 inline void
00194 swap(pair<_T1, _T2>&& __x, pair<_T1, _T2>& __y)
00195 { __x.swap(__y); }
00196
00197 template<class _T1, class _T2>
00198 inline void
00199 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>&& __y)
00200 { __x.swap(__y); }
00201 #endif
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 #ifndef __GXX_EXPERIMENTAL_CXX0X__
00216 template<class _T1, class _T2>
00217 inline pair<_T1, _T2>
00218 make_pair(_T1 __x, _T2 __y)
00219 { return pair<_T1, _T2>(__x, __y); }
00220 #else
00221 template<typename _Tp>
00222 class reference_wrapper;
00223
00224
00225 template<typename _Tp>
00226 struct __strip_reference_wrapper
00227 {
00228 typedef _Tp __type;
00229 };
00230
00231 template<typename _Tp>
00232 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
00233 {
00234 typedef _Tp& __type;
00235 };
00236
00237 template<typename _Tp>
00238 struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
00239 {
00240 typedef _Tp& __type;
00241 };
00242
00243 template<typename _Tp>
00244 struct __decay_and_strip
00245 {
00246 typedef typename __strip_reference_wrapper<
00247 typename decay<_Tp>::type>::__type __type;
00248 };
00249
00250
00251 template<class _T1, class _T2>
00252 inline pair<typename __decay_and_strip<_T1>::__type,
00253 typename __decay_and_strip<_T2>::__type>
00254 make_pair(_T1&& __x, _T2&& __y)
00255 {
00256 return pair<typename __decay_and_strip<_T1>::__type,
00257 typename __decay_and_strip<_T2>::__type>
00258 (std::forward<_T1>(__x), std::forward<_T2>(__y));
00259 }
00260 #endif
00261
00262 _GLIBCXX_END_NAMESPACE
00263
00264 #endif