59 #ifndef EASTL_COMPRESSED_PAIR_H
60 #define EASTL_COMPRESSED_PAIR_H
63 #include <EASTL/internal/config.h>
64 #include <EASTL/type_traits.h>
65 #include <EASTL/bonus/call_traits.h>
67 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
71 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
72 EA_DISABLE_VC_WARNING(4626 5027)
78 template <
typename T1,
typename T2>
79 class compressed_pair;
82 template <
typename T1,
typename T2,
bool isSame,
bool firstEmpty,
bool secondEmpty>
85 template <
typename T1,
typename T2>
88 template <
typename T1,
typename T2>
91 template <
typename T1,
typename T2>
94 template <
typename T1,
typename T2>
97 template <
typename T1,
typename T2>
100 template <
typename T1,
typename T2>
103 template <
typename T1,
typename T2,
int version>
108 template <
typename T>
109 inline void cp_swap(T& t1, T& t2)
118 template <
typename T1,
typename T2>
122 typedef T1 first_type;
123 typedef T2 second_type;
124 typedef typename call_traits<first_type>::param_type first_param_type;
125 typedef typename call_traits<second_type>::param_type second_param_type;
126 typedef typename call_traits<first_type>::reference first_reference;
127 typedef typename call_traits<second_type>::reference second_reference;
128 typedef typename call_traits<first_type>::const_reference first_const_reference;
129 typedef typename call_traits<second_type>::const_reference second_const_reference;
134 : mFirst(x), mSecond(y) {}
142 first_reference first() {
return mFirst; }
143 first_const_reference first()
const {
return mFirst; }
145 second_reference second() {
return mSecond; }
146 second_const_reference second()
const {
return mSecond; }
150 cp_swap(mFirst, y.first());
151 cp_swap(mSecond, y.second());
161 template <
typename T1,
typename T2>
165 typedef T1 first_type;
166 typedef T2 second_type;
167 typedef typename call_traits<first_type>::param_type first_param_type;
168 typedef typename call_traits<second_type>::param_type second_param_type;
169 typedef typename call_traits<first_type>::reference first_reference;
170 typedef typename call_traits<second_type>::reference second_reference;
171 typedef typename call_traits<first_type>::const_reference first_const_reference;
172 typedef typename call_traits<second_type>::const_reference second_const_reference;
177 : first_type(x), mSecond(y) {}
185 first_reference first() {
return *
this; }
186 first_const_reference first()
const {
return *
this; }
188 second_reference second() {
return mSecond; }
189 second_const_reference second()
const {
return mSecond; }
194 cp_swap(mSecond, y.second());
204 template <
typename T1,
typename T2>
208 typedef T1 first_type;
209 typedef T2 second_type;
210 typedef typename call_traits<first_type>::param_type first_param_type;
211 typedef typename call_traits<second_type>::param_type second_param_type;
212 typedef typename call_traits<first_type>::reference first_reference;
213 typedef typename call_traits<second_type>::reference second_reference;
214 typedef typename call_traits<first_type>::const_reference first_const_reference;
215 typedef typename call_traits<second_type>::const_reference second_const_reference;
220 : second_type(y), mFirst(x) {}
228 first_reference first() {
return mFirst; }
229 first_const_reference first()
const {
return mFirst; }
231 second_reference second() {
return *
this; }
232 second_const_reference second()
const {
return *
this; }
237 cp_swap(mFirst, y.first());
247 template <
typename T1,
typename T2>
251 typedef T1 first_type;
252 typedef T2 second_type;
253 typedef typename call_traits<first_type>::param_type first_param_type;
254 typedef typename call_traits<second_type>::param_type second_param_type;
255 typedef typename call_traits<first_type>::reference first_reference;
256 typedef typename call_traits<second_type>::reference second_reference;
257 typedef typename call_traits<first_type>::const_reference first_const_reference;
258 typedef typename call_traits<second_type>::const_reference second_const_reference;
263 : first_type(x), second_type(y) {}
271 first_reference first() {
return *
this; }
272 first_const_reference first()
const {
return *
this; }
274 second_reference second() {
return *
this; }
275 second_const_reference second()
const {
return *
this; }
286 template <
typename T1,
typename T2>
290 typedef T1 first_type;
291 typedef T2 second_type;
292 typedef typename call_traits<first_type>::param_type first_param_type;
293 typedef typename call_traits<second_type>::param_type second_param_type;
294 typedef typename call_traits<first_type>::reference first_reference;
295 typedef typename call_traits<second_type>::reference second_reference;
296 typedef typename call_traits<first_type>::const_reference first_const_reference;
297 typedef typename call_traits<second_type>::const_reference second_const_reference;
307 first_reference first() {
return *
this; }
308 first_const_reference first()
const {
return *
this; }
310 second_reference second() {
return *
this; }
311 second_const_reference second()
const {
return *
this; }
318 template <
typename T1,
typename T2>
322 typedef T1 first_type;
323 typedef T2 second_type;
324 typedef typename call_traits<first_type>::param_type first_param_type;
325 typedef typename call_traits<second_type>::param_type second_param_type;
326 typedef typename call_traits<first_type>::reference first_reference;
327 typedef typename call_traits<second_type>::reference second_reference;
328 typedef typename call_traits<first_type>::const_reference first_const_reference;
329 typedef typename call_traits<second_type>::const_reference second_const_reference;
334 : mFirst(x), mSecond(y) {}
337 : mFirst(x), mSecond(x) {}
339 first_reference first() {
return mFirst; }
340 first_const_reference first()
const {
return mFirst; }
342 second_reference second() {
return mSecond; }
343 second_const_reference second()
const {
return mSecond; }
347 cp_swap(mFirst, y.first());
348 cp_swap(mSecond, y.second());
358 template <
typename T1,
typename T2>
361 compressed_pair_switch<
364 is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
366 is_empty<T2>::value>::value>
377 typedef T1 first_type;
378 typedef T2 second_type;
379 typedef typename call_traits<first_type>::param_type first_param_type;
380 typedef typename call_traits<second_type>::param_type second_param_type;
381 typedef typename call_traits<first_type>::reference first_reference;
382 typedef typename call_traits<second_type>::reference second_reference;
383 typedef typename call_traits<first_type>::const_reference first_const_reference;
384 typedef typename call_traits<second_type>::const_reference second_const_reference;
391 first_reference first() {
return base::first(); }
392 first_const_reference first()
const {
return base::first(); }
394 second_reference second() {
return base::second(); }
395 second_const_reference second()
const {
return base::second(); }
402 template <
typename T>
405 compressed_pair_switch<
408 is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
410 is_empty<T>::value>::value>
421 typedef T first_type;
422 typedef T second_type;
423 typedef typename call_traits<first_type>::param_type first_param_type;
424 typedef typename call_traits<second_type>::param_type second_param_type;
425 typedef typename call_traits<first_type>::reference first_reference;
426 typedef typename call_traits<second_type>::reference second_reference;
427 typedef typename call_traits<first_type>::const_reference first_const_reference;
428 typedef typename call_traits<second_type>::const_reference second_const_reference;
434 first_reference first() {
return base::first(); }
435 first_const_reference first()
const {
return base::first(); }
437 second_reference second() {
return base::second(); }
438 second_const_reference second()
const {
return base::second(); }
444 template <
typename T1,
typename T2>
453 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
454 EA_RESTORE_VC_WARNING()
Definition: compressed_pair.h:411
Definition: compressed_pair.h:104
Definition: compressed_pair.h:367
EA Standard Template Library.
Definition: algorithm.h:288
Definition: compressed_pair.h:83
Definition: type_pod.h:57
Definition: type_traits.h:604