Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_tuple.h
Go to the documentation of this file.
1// -*- C++ -*-
2
33#ifndef _RWSTD_RW_TUPLE_H_INCLUDED
34# define _RWSTD_RW_TUPLE_H_INCLUDED
35
36# include <rw/_defs.h>
37
38# include <rw/_allocator.h> // for std::allocator_arg_t
39# include <rw/_forward.h> // for _RWSTD_FORWARD, _RWSTD_MOVE
40# include <rw/_meta_other.h> // for _RWSTD_DECAY
41
42
44
45template <class _TypeT>
46class reference_wrapper;
47
48} // namespace std
49
50
52
53
54// internal tuple class template
55
56# if !defined _RWSTD_NO_VARIADIC_TEMPLATES
57
58template <class... _TypesT>
59class __rw_tuple;
60
62class __rw_tuple<>
63{
64 // empty
65};
66
67template <class _HeadT, class... _TailT>
68class __rw_tuple<_HeadT, _TailT...>
69 : public __rw_tuple<_TailT...>
70{
71 typedef __rw_tuple<_TailT...> _Base;
72
73 _HeadT _C_data;
74
75public:
76
77 __rw_tuple ()
78 : _Base (), _C_data () { /* empty */ }
79
80 __rw_tuple (const __rw_tuple& __tuple)
81 : _Base (__tuple._C_tail ())
82 , _C_data (__tuple._C_data) { /* empty */ }
83
84 __rw_tuple& operator= (const __rw_tuple& __tuple) {
85 _Base::operator= (__tuple._C_tail ());
86 _C_data = __tuple._C_data;
87 return *this;
88 }
89
90 explicit
91 __rw_tuple (const _HeadT& __head, const _TailT&... __tail)
92 : _Base (__tail...), _C_data (__head) { /* empty */ }
93
94 template <class _HeadU, class... _TailU>
95 __rw_tuple (const __rw_tuple<_HeadU, _TailU...>& __tuple)
96 : _Base (__tuple._C_tail ())
97 , _C_data (__tuple._C_head ()) { /* empty */ }
98
99 template <class _HeadU, class... _TailU>
100 __rw_tuple& operator= (const __rw_tuple<_HeadU, _TailU...>& __tuple) {
101 _Base::operator= (__tuple._C_tail ());
102 _C_data = __tuple._C_head ();
103 return *this;
104 }
105
106# if !defined _RWSTD_NO_RVALUE_REFERENCES
107
108 __rw_tuple (__rw_tuple&& __tuple)
109 : _Base (_STD::move<_Base&&> (__tuple._C_tail ()))
110 , _C_data (_RWSTD_FORWARD (_HeadT, __tuple._C_data)) { /* empty */ }
111
112 __rw_tuple& operator= (__rw_tuple&& __tuple) {
113 _Base::operator= (_RWSTD_FORWARD (_Base, __tuple._C_tail ()));
114 _C_data = _RWSTD_MOVE (__tuple._C_data);
115 return *this;
116 }
117
118 template <class _HeadU, class... _TailU>
119 explicit __rw_tuple (_HeadU&& __head, _TailU&&... __tail)
120 : _Base (_RWSTD_FORWARD (_TailU, __tail)...)
121 , _C_data (_RWSTD_MOVE (__head)) { /* empty */ }
122
123 template <class _HeadU, class... _TailU>
124 __rw_tuple (__rw_tuple<_HeadU, _TailU...>&& __tuple)
125 : _Base (_RWSTD_MOVE (__tuple._C_tail ()))
126 , _C_data (_RWSTD_MOVE (__tuple._C_head ())) { /* empty */ }
127
128 template <class _HeadU, class... _TailU>
129 __rw_tuple& operator= (__rw_tuple<_HeadU, _TailU...>&& __tuple) {
130 _Base::operator= (_RWSTD_MOVE (__tuple._C_tail ()));
131 _C_data = _RWSTD_MOVE (__tuple._C_head ());
132 return *this;
133 }
134
135 // allocator-extended constructors:
136
137 template <class _Alloc, class... _TypesU>
138 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
139 const _TypesU&&... __values);
140
141 template <class _Alloc>
142 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
143 __rw_tuple&& __tuple);
144
145 template <class _Alloc, class... _TypesU>
146 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
147 __rw_tuple<_TypesU...>&& __tuple);
148
149# endif // !defined _RWSTD_NO_RVALUE_REFERENCES
150
151 template <class _Alloc>
152 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc);
153
154 template <class _Alloc>
155 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
156 const _HeadT& __head, const _TailT&... __tail);
157
158 template <class _Alloc>
159 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
160 const __rw_tuple& __tuple);
161
162 template <class _Alloc, class... _TypesU>
163 __rw_tuple (_STD::allocator_arg_t, const _Alloc& __alloc,
164 const __rw_tuple<_TypesU...>& __tuple);
165
166 // accessors:
167
168 _HeadT& _C_head () { return _C_data; }
169 const _HeadT& _C_head () const { return _C_data; }
170
171 _Base& _C_tail () { return *this; }
172 const _Base& _C_tail () const { return *this; }
173
174};
175
176
177struct __rw_ignore
178{
179 template <class _TypeT>
180 void operator= (const _TypeT&) const {}
181};
182
183
184template <class _TypeT>
185struct __rw_deduce_ref
186{
187 typedef _TypeT _C_type;
188};
189
190template <class _TypeT>
191struct __rw_deduce_ref<_STD::reference_wrapper<_TypeT> >
192{
193 typedef _TypeT& _C_type;
194};
195
196template <class _TypeT>
197struct __rw_deduce_ref<const _STD::reference_wrapper<_TypeT> >
198{
199 typedef _TypeT& _C_type;
200};
201
202template <class _TypeT>
203struct __rw_make_tuple
204{
205 typedef typename _RWSTD_DECAY (_TypeT) _C_decay;
206 typedef typename __rw_deduce_ref<_C_decay>::_C_type _C_type;
207};
208
209
210template <class... _TypesT, class... _TypesU>
211bool operator== (const __rw_tuple<_TypesT...>& __x,
212 const __rw_tuple<_TypesU...>& __y) {
213 return (__x._C_head () == __y._C_head ())
214 && (__x._C_tail () == __y._C_tail ());
215}
216
218bool operator== (const __rw_tuple<>& /*__x*/,
219 const __rw_tuple<>& /*__y*/) {
220 return true;
221}
222
223template <class... _TypesT, class... _TypesU>
224bool operator< (const __rw_tuple<_TypesT...>& __x,
225 const __rw_tuple<_TypesU...>& __y) {
226 return (__x._C_head () < __y._C_head ())
227 || ( !(__y._C_head () < __x._C_head ())
228 && (__x._C_tail () < __y._C_tail ()));
229}
230
232bool operator< (const __rw_tuple<>& /*__x*/,
233 const __rw_tuple<>& /*__y*/) {
234 return false;
235}
236
237# endif // !defined _RWSTD_NO_VARIADIC_TEMPLATES
238
239
240} // namespace __rw
241
242
243#endif // _RWSTD_TUPLE_INCLUDED
#define _RWSTD_SPECIALIZED_CLASS
#define _STD
Definition _defs.h:571
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_SPECIALIZED_FUNCTION
Definition _defs.h:556
#define _RWSTD_MOVE(__x)
#define _RWSTD_FORWARD(_TypeT, __x)
#define _RWSTD_DECAY(T)
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14737
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14787
Definition json.h:5363