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 #ifndef _STL_PAIR_H
00058 #define _STL_PAIR_H 1
00059
00060 #include <bits/move.h>
00061
00062
00063 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00064 #include <type_traits>
00065 #endif
00066
00067 _GLIBCXX_BEGIN_NAMESPACE(std)
00068
00069
00070 template<class _T1, class _T2>
00071 struct pair
00072 {
00073 typedef _T1 first_type;
00074 typedef _T2 second_type;
00075
00076 _T1 first;
00077 _T2 second;
00078
00079
00080
00081
00082
00083 pair()
00084 : first(), second() { }
00085
00086
00087 pair(const _T1& __a, const _T2& __b)
00088 : first(__a), second(__b) { }
00089
00090 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00091
00092 template<class _U1, class = typename
00093 std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
00094 pair(_U1&& __x, const _T2& __y)
00095 : first(std::forward<_U1>(__x)),
00096 second(__y) { }
00097
00098 template<class _U2, class = typename
00099 std::enable_if<std::is_convertible<_U2, _T2>::value>::type>
00100 pair(const _T1& __x, _U2&& __y)
00101 : first(__x),
00102 second(std::forward<_U2>(__y)) { }
00103
00104 template<class _U1, class _U2, class = typename
00105 std::enable_if<std::is_convertible<_U1, _T1>::value
00106 && std::is_convertible<_U2, _T2>::value>::type>
00107 pair(_U1&& __x, _U2&& __y)
00108 : first(std::forward<_U1>(__x)),
00109 second(std::forward<_U2>(__y)) { }
00110
00111 pair(pair&& __p)
00112 : first(std::move(__p.first)),
00113 second(std::move(__p.second)) { }
00114 #endif
00115
00116
00117 template<class _U1, class _U2>
00118 pair(const pair<_U1, _U2>& __p)
00119 : first(__p.first),
00120 second(__p.second) { }
00121
00122 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00123 template<class _U1, class _U2>
00124 pair(pair<_U1, _U2>&& __p)
00125 : first(std::move(__p.first)),
00126 second(std::move(__p.second)) { }
00127
00128 pair&
00129 operator=(pair&& __p)
00130 {
00131 first = std::move(__p.first);
00132 second = std::move(__p.second);
00133 return *this;
00134 }
00135
00136 template<class _U1, class _U2>
00137 pair&
00138 operator=(pair<_U1, _U2>&& __p)
00139 {
00140 first = std::move(__p.first);
00141 second = std::move(__p.second);
00142 return *this;
00143 }
00144
00145 void
00146 swap(pair& __p)
00147 {
00148 using std::swap;
00149 swap(first, __p.first);
00150 swap(second, __p.second);
00151 }
00152 #endif
00153 };
00154
00155
00156 template<class _T1, class _T2>
00157 inline bool
00158 operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00159 { return __x.first == __y.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.first < __y.first
00166 || (!(__y.first < __x.first) && __x.second < __y.second); }
00167
00168
00169 template<class _T1, class _T2>
00170 inline bool
00171 operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00172 { return !(__x == __y); }
00173
00174
00175 template<class _T1, class _T2>
00176 inline bool
00177 operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00178 { return __y < __x; }
00179
00180
00181 template<class _T1, class _T2>
00182 inline bool
00183 operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00184 { return !(__y < __x); }
00185
00186
00187 template<class _T1, class _T2>
00188 inline bool
00189 operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00190 { return !(__x < __y); }
00191
00192 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00193
00194 // Note: no std::swap overloads in C++03 mode, this has performance
00195
00196 template<class _T1, class _T2>
00197 inline void
00198 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
00199 { __x.swap(__y); }
00200 #endif
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 #ifndef __GXX_EXPERIMENTAL_CXX0X__
00215 template<class _T1, class _T2>
00216 inline pair<_T1, _T2>
00217 make_pair(_T1 __x, _T2 __y)
00218 { return pair<_T1, _T2>(__x, __y); }
00219 #else
00220 template<typename _Tp>
00221 class reference_wrapper;
00222
00223
00224 template<typename _Tp>
00225 struct __strip_reference_wrapper
00226 {
00227 typedef _Tp __type;
00228 };
00229
00230 template<typename _Tp>
00231 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
00232 {
00233 typedef _Tp& __type;
00234 };
00235
00236 template<typename _Tp>
00237 struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
00238 {
00239 typedef _Tp& __type;
00240 };
00241
00242 template<typename _Tp>
00243 struct __decay_and_strip
00244 {
00245 typedef typename __strip_reference_wrapper<
00246 typename decay<_Tp>::type>::__type __type;
00247 };
00248
00249
00250 template<class _T1, class _T2>
00251 inline pair<typename __decay_and_strip<_T1>::__type,
00252 typename __decay_and_strip<_T2>::__type>
00253 make_pair(_T1&& __x, _T2&& __y)
00254 {
00255 return pair<typename __decay_and_strip<_T1>::__type,
00256 typename __decay_and_strip<_T2>::__type>
00257 (std::forward<_T1>(__x), std::forward<_T2>(__y));
00258 }
00259 #endif
00260
00261 _GLIBCXX_END_NAMESPACE
00262
00263 #endif