Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_ref_wrap.h
Go to the documentation of this file.
1// -*- C++ -*-
2
33#ifndef _RWSTD_RW_REF_WRAP_INCLUDED
34# define _RWSTD_RW_REF_WRAP_INCLUDED
35
36# include <rw/_defs.h>
37
38
40
41
42// 20.5.5, class template reference_wrapper:
43
44template <class _TypeT>
45class reference_wrapper
46{
47 _TypeT* _C_ptr;
48
49public:
50
51 typedef _TypeT type;
52
53 reference_wrapper (type& __x)
54 : _C_ptr (&__x) { /* empty */ }
55
56 reference_wrapper (const reference_wrapper& __x)
57 : _C_ptr (__x._C_ptr) { /* empty */ }
58
59 reference_wrapper& operator= (const reference_wrapper& __x) {
60 _RWSTD_ASSERT (0 != __x._C_ptr);
61 _C_ptr = __x._C_ptr;
62 return *this;
63 }
64
65 operator type& () const {
66 _RWSTD_ASSERT (0 != _C_ptr);
67 return *_C_ptr;
68 }
69
70 type& get() const {
71 _RWSTD_ASSERT (0 != _C_ptr);
72 return *_C_ptr;
73 }
74};
75
76
77template <class _TypeT>
78inline reference_wrapper<_TypeT>
79ref (_TypeT& __x)
80{
81 return reference_wrapper<_TypeT> (__x);
82}
83
84template <class _TypeT>
85inline reference_wrapper<_TypeT>
86ref (reference_wrapper<_TypeT>& __x)
87{
88 return reference_wrapper<_TypeT> (__x);
89}
90
91
92template <class _TypeT>
93inline reference_wrapper<const _TypeT>
94cref (const _TypeT& __x)
95{
96 return reference_wrapper<const _TypeT> (__x);
97}
98
99template <class _TypeT>
100inline reference_wrapper<const _TypeT>
101cref (reference_wrapper<const _TypeT>& __x)
102{
103 return reference_wrapper<const _TypeT> (__x);
104}
105
106
107} // namespace std
108
109
110#endif // _RWSTD_RW_REF_WRAP_INCLUDED
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
Definition json.h:5363