|
|
|
| 1 |
|
// tuple TR1 header |
| 2 |
|
|
| 3 |
|
#pragma once |
| 4 |
|
#ifndef _TUPLE_ |
| 5 |
|
#define _TUPLE_ |
| 6 |
|
#ifndef RC_INVOKED |
| 7 |
|
#include <xutility> |
| 8 |
|
#include <xrefwrap> |
| 9 |
|
|
| 10 |
|
#pragma pack(push,_CRT_PACKING) |
| 11 |
|
#pragma warning(push,3) |
| 12 |
|
|
| 13 |
|
_STD_BEGIN |
| 14 |
|
namespace tr1 { // TR1 additions |
| 15 |
|
|
| 16 |
|
// TEMPLATE STRUCT _Arg_traits |
| 17 |
|
template<class _Ty> |
| 18 |
|
struct _Arg_traits |
| 19 |
|
{ // template that transforms argument types |
| 20 |
|
typedef const _Ty& _CType; |
| 21 |
|
typedef _Ty& _RType; |
| 22 |
|
typedef const _Ty& _AType; |
| 23 |
|
typedef _Ty _VType; |
| 24 |
|
}; |
| 25 |
|
|
| 26 |
|
template<class _Ty> |
| 27 |
|
struct _Arg_traits<_Ty&> |
| 28 |
|
{ // template specialization for arguments passed by reference |
| 29 |
|
typedef _Ty& _CType; |
| 30 |
|
typedef _Ty& _RType; |
| 31 |
|
typedef _Ty& _AType; |
| 32 |
|
typedef _Ty& _VType; |
| 33 |
|
}; |
| 34 |
|
|
| 35 |
|
template<class _Ty> |
| 36 |
|
struct _Arg_traits<const reference_wrapper<_Ty>&> |
| 37 |
|
{ // template specialization for reference_wrapper arguments |
| 38 |
|
typedef const _Ty& _CType; |
| 39 |
|
typedef _Ty& _RType; |
| 40 |
|
typedef _Ty& _AType; |
| 41 |
|
typedef _Ty& _VType; |
| 42 |
|
}; |
| 43 |
|
|
| 44 |
|
// TEMPLATE FUNCTION _Assign |
| 45 |
|
template<class _Tgt, |
| 46 |
|
class _Src> inline |
| 47 |
|
void _Assign(_Tgt& _Tx, _Src _Sx) |
| 48 |
|
{ // assign _Sx to _Tx |
| 49 |
|
_Tx = _Sx; |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
template<class _Tgt, |
| 53 |
|
class _Src> inline |
| 54 |
|
void _Assign(reference_wrapper<_Tgt> _Tx, _Src _Sx) |
| 55 |
|
{ // assign _Sx to _Tx.get() |
| 56 |
|
_Tx.get() = _Sx; |
| 475 |
|
{ // determine tuple element type for tuple returned by make_tuple |
| 476 |
|
typedef _Ty& _Type; |
| 477 |
|
}; |
| 478 |
|
|
| 479 |
|
// TEMPLATE STRUCT _Make_tuple |
| 480 |
|
template<_CLASS_ARG0_DEF_MAX> |
| 481 |
|
struct _Make_tuple |
| 482 |
|
{ // determine tuple element type for tuple returned by make_tuple |
| 483 |
|
typedef tuple<_LIST15_MAX(typename _Ttype<_Arg, >::_Type)> _Type; |
| 484 |
|
}; |
| 485 |
|
|
| 486 |
|
// TEMPLATE FUNCTION make_tuple, TEMPLATE FUNCTION tie |
| 487 |
|
#define _INCL_FILE "xxtuple1" |
| 488 |
|
#include "xfwrap" |
| 489 |
|
|
| 490 |
|
} // namespace tr1 |
| 491 |
|
|
| 492 |
|
// tuple implements a performant swap |
| 493 |
|
template<_CLASS_ARG0_MAX> |
| 494 |
|
class _Move_operation_category<tr1::tuple<_ARG0_ARG1_MAX> > |
| 495 |
|
{ // tuple implements a performant swap if all elements do |
| 496 |
|
public: |
| 497 |
|
typedef typename _If< |
| 498 |
|
_Is_swap_move<typename _Move_operation_category< |
| 499 |
|
_Arg0>::_Move_cat>::_Value && |
| 500 |
|
_Is_swap_move<typename _Move_operation_category< |
| 501 |
|
tr1::tuple<_ARG1_ARG2_MAX> >::_Move_cat>::_Value, |
| 502 |
|
_Swap_move_tag, |
| 503 |
|
_Undefined_move_tag>::_Result _Move_cat; |
| 504 |
|
}; |
| 505 |
|
|
| 506 |
|
template<> |
| 507 |
|
class _Move_operation_category<tr1::tuple<> > |
| 508 |
|
{ // empty tuple implements a performant swap |
| 509 |
|
public: |
| 510 |
|
typedef _Swap_move_tag _Move_cat; |
| 511 |
|
}; |
| 512 |
|
_STD_END |
| 513 |
|
#pragma warning(pop) |
| 514 |
|
#pragma pack(pop) |
| 515 |
|
|
| 516 |
|
#endif /* RC_INVOKED */ |
| 517 |
|
#endif /* _TUPLE_ */ |
| 518 |
|
|
| 519 |
|
/* |
| 520 |
|
* Copyright (c) 1992-2008 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 521 |
|
* Consult your license regarding permissions and restrictions. |
| 522 |
|
V5.05:0009 */ |
| 523 |
|
|
|
|
|