|
|
|
| 1 |
|
// xrefwrap internal header |
| 2 |
|
#ifndef _XREFWRAP_ |
| 3 |
|
#define _XREFWRAP_ |
| 4 |
|
#include <xtr1common> |
| 5 |
|
|
| 6 |
|
_STD_BEGIN |
| 7 |
|
namespace tr1 { // TR1 additions |
| 8 |
|
|
| 9 |
|
// IMPLEMENT std::tr1::result_of |
| 10 |
|
// TEMPLATE STRUCT _Copy_cv |
| 11 |
|
template<class _Tgt, |
| 12 |
|
class _Src> |
| 13 |
|
struct _Copy_cv |
| 14 |
|
{ // plain version |
| 15 |
|
typedef _Tgt& _Type; |
| 16 |
|
}; |
| 17 |
|
|
| 18 |
|
template<class _Tgt, |
| 19 |
|
class _Src> |
| 20 |
|
struct _Copy_cv<_Tgt, const _Src&> |
| 21 |
|
{ // const version |
| 22 |
|
typedef const _Tgt& _Type; |
| 23 |
|
}; |
| 24 |
|
|
| 25 |
|
template<class _Tgt, |
| 26 |
|
class _Src> |
| 27 |
|
struct _Copy_cv<_Tgt, volatile _Src&> |
| 28 |
|
{ // volatile version |
| 29 |
|
typedef volatile _Tgt& _Type; |
| 30 |
|
}; |
| 31 |
|
|
| 32 |
|
template<class _Tgt, |
| 33 |
|
class _Src> |
| 34 |
|
struct _Copy_cv<_Tgt, const volatile _Src&> |
| 35 |
|
{ // const volatile version |
| 36 |
|
typedef const volatile _Tgt& _Type; |
| 37 |
|
}; |
| 38 |
|
|
| 39 |
|
// TEMPLATE STRUCT _Result_of |
| 40 |
|
template<class _Ty> |
| 41 |
|
struct _Result_of; |
| 42 |
|
|
| 43 |
|
#define _INCL_FILE <xxresult> |
| 44 |
|
#include <xfwrap> |
| 45 |
|
|
| 46 |
|
// TEMPLATE STRUCT result_of |
| 47 |
|
template<class _Fty> |
| 48 |
|
struct result_of |
| 49 |
|
{ // template to determine result of call operation |
| 50 |
|
typedef typename _Result_of<_Fty>::_Type type; |
| 51 |
|
}; |
| 52 |
|
|
| 53 |
|
// SUPPORT CLASSES FOR CALL WRAPPERS |
| 454 |
|
{ // construct |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
operator _Ty&() const |
| 458 |
|
{ // return reference |
| 459 |
|
return (this->_Get()); |
| 460 |
|
} |
| 461 |
|
|
| 462 |
|
_Ty& get() const |
| 463 |
|
{ // return reference |
| 464 |
|
return (this->_Get()); |
| 465 |
|
} |
| 466 |
|
}; |
| 467 |
|
|
| 468 |
|
// TEMPLATE FUNCTIONS ref AND cref |
| 469 |
|
template<class _Ty> |
| 470 |
|
reference_wrapper<_Ty> ref(_Ty& _Val) |
| 471 |
|
{ // create reference_wrapper<_Ty> object |
| 472 |
|
return (reference_wrapper<_Ty>(_Val)); |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
template<class _Ty> |
| 476 |
|
reference_wrapper<_Ty> ref(reference_wrapper<_Ty> _Val) |
| 477 |
|
{ // create reference_wrapper<_Ty> object |
| 478 |
|
return (_Val); |
| 479 |
|
} |
| 480 |
|
|
| 481 |
|
template<class _Ty> |
| 482 |
|
reference_wrapper<const _Ty> cref(const _Ty& _Val) |
| 483 |
|
{ // create reference_wrapper<const _Ty> object |
| 484 |
|
return (reference_wrapper<const _Ty>(_Val)); |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
template<class _Ty> |
| 488 |
|
reference_wrapper<const _Ty> cref(reference_wrapper<const _Ty> _Val) |
| 489 |
|
{ // create reference_wrapper<const _Ty> object |
| 490 |
|
return (_Val); |
| 491 |
|
} |
| 492 |
|
|
| 493 |
|
} // namespace tr1 |
| 494 |
|
_STD_END |
| 495 |
|
#endif // _XREFWRAP_ |
| 496 |
|
|
| 497 |
|
|
| 498 |
|
/* |
| 499 |
|
* Copyright (c) 1992-2008 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 500 |
|
* Consult your license regarding permissions and restrictions. |
| 501 |
|
V5.05:0009 */ |
| 502 |
|
|
|
|
|