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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00063 #include <type_traits>
00064 #endif
00065
00066 namespace std _GLIBCXX_VISIBILITY(default)
00067 {
00068 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00069
00070 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00071
00072 struct piecewise_construct_t { };
00073
00074
00075 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
00076
00077
00078 template<typename...>
00079 class tuple;
00080
00081 template<int...>
00082 struct _Index_tuple;
00083 #endif
00084
00085
00086 template<class _T1, class _T2>
00087 struct pair
00088 {
00089 typedef _T1 first_type;
00090 typedef _T2 second_type;
00091
00092 _T1 first;
00093 _T2 second;
00094
00095
00096
00097
00098
00099 _GLIBCXX_CONSTEXPR pair()
00100 : first(), second() { }
00101
00102
00103 _GLIBCXX_CONSTEXPR pair(const _T1& __a, const _T2& __b)
00104 : first(__a), second(__b) { }
00105
00106
00107 template<class _U1, class _U2>
00108 _GLIBCXX_CONSTEXPR pair(const pair<_U1, _U2>& __p)
00109 : first(__p.first), second(__p.second) { }
00110
00111 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00112 constexpr pair(const pair&) = default;
00113
00114
00115
00116
00117
00118 template<class _U1, class = typename
00119 std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
00120 pair(_U1&& __x, const _T2& __y)
00121 : first(std::forward<_U1>(__x)), second(__y) { }
00122
00123 template<class _U2, class = typename
00124 std::enable_if<std::is_convertible<_U2, _T2>::value>::type>
00125 pair(const _T1& __x, _U2&& __y)
00126 : first(__x), second(std::forward<_U2>(__y)) { }
00127
00128 template<class _U1, class _U2, class = typename
00129 std::enable_if<std::is_convertible<_U1, _T1>::value
00130 && std::is_convertible<_U2, _T2>::value>::type>
00131 pair(_U1&& __x, _U2&& __y)
00132 : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
00133
00134 template<class _U1, class _U2>
00135 pair(pair<_U1, _U2>&& __p)
00136 : first(std::forward<_U1>(__p.first)),
00137 second(std::forward<_U2>(__p.second)) { }
00138
00139 template<class... _Args1, class... _Args2>
00140 pair(piecewise_construct_t,
00141 tuple<_Args1...> __first, tuple<_Args2...> __second)
00142 : first(__cons<first_type>(std::move(__first))),
00143 second(__cons<second_type>(std::move(__second))) { }
00144
00145 pair&
00146 operator=(const pair& __p)
00147 {
00148 first = __p.first;
00149 second = __p.second;
00150 return *this;
00151 }
00152
00153 pair&
00154 operator=(pair&& __p)
00155 {
00156 first = std::move(__p.first);
00157 second = std::move(__p.second);
00158 return *this;
00159 }
00160
00161 template<class _U1, class _U2>
00162 pair&
00163 operator=(const pair<_U1, _U2>& __p)
00164 {
00165 first = __p.first;
00166 second = __p.second;
00167 return *this;
00168 }
00169
00170 template<class _U1, class _U2>
00171 pair&
00172 operator=(pair<_U1, _U2>&& __p)
00173 {
00174 first = std::move(__p.first);
00175 second = std::move(__p.second);
00176 return *this;
00177 }
00178
00179 void
00180 swap(pair& __p)
00181 {
00182 using std::swap;
00183 swap(first, __p.first);
00184 swap(second, __p.second);
00185 }
00186
00187 private:
00188 template<typename _Tp, typename... _Args>
00189 static _Tp
00190 __cons(tuple<_Args...>&&);
00191
00192 template<typename _Tp, typename... _Args, int... _Indexes>
00193 static _Tp
00194 __do_cons(tuple<_Args...>&&, const _Index_tuple<_Indexes...>&);
00195 #endif
00196 };
00197
00198
00199 template<class _T1, class _T2>
00200 inline _GLIBCXX_CONSTEXPR bool
00201 operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00202 { return __x.first == __y.first && __x.second == __y.second; }
00203
00204
00205 template<class _T1, class _T2>
00206 inline _GLIBCXX_CONSTEXPR bool
00207 operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00208 { return __x.first < __y.first
00209 || (!(__y.first < __x.first) && __x.second < __y.second); }
00210
00211
00212 template<class _T1, class _T2>
00213 inline _GLIBCXX_CONSTEXPR bool
00214 operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00215 { return !(__x == __y); }
00216
00217
00218 template<class _T1, class _T2>
00219 inline _GLIBCXX_CONSTEXPR bool
00220 operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00221 { return __y < __x; }
00222
00223
00224 template<class _T1, class _T2>
00225 inline _GLIBCXX_CONSTEXPR bool
00226 operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00227 { return !(__y < __x); }
00228
00229
00230 template<class _T1, class _T2>
00231 inline _GLIBCXX_CONSTEXPR bool
00232 operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00233 { return !(__x < __y); }
00234
00235 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00236
00237
00238
00239 template<class _T1, class _T2>
00240 inline void
00241 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
00242 { __x.swap(__y); }
00243 #endif
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00258
00259 template<class _T1, class _T2>
00260 inline pair<typename __decay_and_strip<_T1>::__type,
00261 typename __decay_and_strip<_T2>::__type>
00262 make_pair(_T1&& __x, _T2&& __y)
00263 {
00264 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
00265 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
00266 typedef pair<__ds_type1, __ds_type2> __pair_type;
00267 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
00268 }
00269 #else
00270 template<class _T1, class _T2>
00271 inline pair<_T1, _T2>
00272 make_pair(_T1 __x, _T2 __y)
00273 { return pair<_T1, _T2>(__x, __y); }
00274 #endif
00275
00276 _GLIBCXX_END_NAMESPACE_VERSION
00277 }
00278
00279 #endif