CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
vpos_type.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_vpos_type_cc_h__
13#define __cxz_vpos_type_cc_h__
14
15#include "vpos_type.h"
16#include "pos_type.h"
17
18namespace CNORXZ
19{
20 /*==========+
21 | VPos |
22 +==========*/
23
24 template <class PosT>
25 VPos<PosT>::VPos(const PosT& a) :
26 PosT(a)
27 {}
28
29 template <class PosT>
31 {
32 return std::make_unique<VPos<PosT>>(*this);
33 }
34
35 template <class PosT>
37 {
38 return this;
39 }
40
41 template <class PosT>
43 {
44 return this->size();
45 }
46
47 template <class PosT>
49 {
50 return this->val();
51 }
52
53 template <class PosT>
55 {
56 return nullptr;
57 }
58
59 template <class PosT>
61 {
62 typedef decltype((*this) + UPos(a->vval())) OPosT;
63 return std::make_unique<VPos<OPosT>>((*this) + UPos(a->vval()));
64 }
65
66 template <class PosT>
68 {
69 typedef decltype((*this) * UPos(a->vval())) OPosT;
70 return std::make_unique<VPos<OPosT>>((*this) * UPos(a->vval()));
71 }
72
73 template <class PosT>
75 {
76 typedef decltype((*this)(UPos(a->vval()))) OPosT;
77 return std::make_unique<VPos<OPosT>>( (*this)(UPos(a->vval())) );
78 }
79
80 /*================+
81 | VPos<MPos> |
82 +================*/
83
84 template <class PosT1, class PosT2>
85 VPos<MPos<PosT1,PosT2>>::VPos(const VPos& a) :
86 MPos<PosT1,PosT2>(a),
87 mTRef(static_cast<const PosT1*>(this))
88 {
90 mNRef = VPosRef<PosT2>(&this->next());
91 }
92 }
94 template <class PosT1, class PosT2>
96 {
98 mTRef = VPosRef<PosT1>(static_cast<const PosT1*>(this));
100 mNRef = VPosRef<PosT2>(&this->next());
101 }
102 return *this;
103 }
104
105 template <class PosT1, class PosT2>
107 MPos<PosT1,PosT2>(a),
108 mTRef(static_cast<const PosT1*>(this))
109 {
111 mNRef = VPosRef<PosT2>(&this->next());
112 }
113 }
114
115 template <class PosT1, class PosT2>
117 {
118 return std::make_unique<VPos<MPos<PosT1,PosT2>>>(*this);
119 }
120
121 template <class PosT1, class PosT2>
122 const VPosBase* VPos<MPos<PosT1,PosT2>>::vget() const
123 {
124 return &mTRef;
125 }
126
127 template <class PosT1, class PosT2>
129 {
130 return this->size();
131 }
132
133 template <class PosT1, class PosT2>
135 {
136 return this->val();
137 }
138
139 template <class PosT1, class PosT2>
140 const VPosBase* VPos<MPos<PosT1,PosT2>>::vnext() const
141 {
143 return &mNRef;
144 }
145 else {
146 return this->next().get();
147 }
148 }
149
150 template <class PosT1, class PosT2>
152 {
153 typedef decltype((*this) + PosFromVPos<MPos<PosT1,PosT2>>::make(a)) OPosT;
154 return std::make_unique<VPos<OPosT>>((*this) + PosFromVPos<MPos<PosT1,PosT2>>::make(a));
155 }
156
157 template <class PosT1, class PosT2>
159 {
160 typedef decltype((*this) * UPos(a->vval())) OPosT;
161 return std::make_unique<VPos<OPosT>>((*this) * UPos(a->vval()));
162 }
163
164 template <class PosT1, class PosT2>
166 {
167 typedef decltype( (*this)(UPos(a->vval())) ) OPosT;
168 return std::make_unique<VPos<OPosT>>( (*this)(UPos(a->vval())) );
169 }
170
171 /*=============+
172 | VPosRef |
173 +=============*/
174
175 template <class PosT>
176 VPosRef<PosT>::VPosRef(const PosT* c) :
177 mC(c)
178 {}
179
180 template <class PosT>
182 {
183 return std::make_unique<VPos<PosT>>(*mC);
184 }
185
186 template <class PosT>
188 {
189 return this;
190 }
191
192 template <class PosT>
194 {
195 return mC->size();
196 }
197
198 template <class PosT>
200 {
201 return mC->val();
202 }
203
204 template <class PosT>
206 {
207 return nullptr;
208 }
209
210 template <class PosT>
212 {
213 typedef decltype((*mC) + UPos(a->vval())) OPosT;
214 return std::make_unique<VPos<OPosT>>((*mC) + UPos(a->vval()));
215 }
216
217 template <class PosT>
219 {
220 typedef decltype((*mC) * UPos(a->vval())) OPosT;
221 return std::make_unique<VPos<OPosT>>((*mC) * UPos(a->vval()));
222 }
223
224 template <class PosT>
226 {
227 typedef decltype( (*mC)(UPos(a->vval())) ) OPosT;
228 return std::make_unique<VPos<OPosT>>( (*mC)(UPos(a->vval())) );
229 }
230
231 /*===================+
232 | VPosRef<MPos> |
233 +===================*/
234
235 template <class PosT1, class PosT2>
237 mC(c),
238 mTRef(static_cast<const PosT1*>(mC))
239 {
241 mNRef = VPosRef<PosT2>(&c->next());
242 }
243 }
244
245 template <class PosT1, class PosT2>
247 {
248 return std::make_unique<VPos<MPos<PosT1,PosT2>>>(*mC);
249 }
250
251 template <class PosT1, class PosT2>
253 {
254 return &mTRef;
255 }
256
257 template <class PosT1, class PosT2>
259 {
260 return mC->size();
261 }
262
263 template <class PosT1, class PosT2>
265 {
266 return mC->val();
267 }
268
269 template <class PosT1, class PosT2>
270 const VPosBase* VPosRef<MPos<PosT1,PosT2>>::vnext() const
271 {
273 return &mNRef;
274 }
275 else {
276 return mC->next().get();
277 }
278 }
279
280 template <class PosT1, class PosT2>
282 {
283 typedef decltype((*mC) + PosFromVPos<MPos<PosT1,PosT2>>::make(a)) OPosT;
284 return std::make_unique<VPos<OPosT>>((*mC) + PosFromVPos<MPos<PosT1,PosT2>>::make(a));
285 }
286
287 template <class PosT1, class PosT2>
289 {
290 typedef decltype((*mC) * UPos(a->vval())) OPosT;
291 return std::make_unique<VPos<OPosT>>((*mC) * UPos(a->vval()));
292 }
293
294 template <class PosT1, class PosT2>
296 {
297 typedef decltype( (*mC)(UPos(a->vval())) ) OPosT;
298 return std::make_unique<VPos<OPosT>>( (*mC)(UPos(a->vval())) );
299 }
300
301 /*=================+
302 | PosFromVPos |
303 +=================*/
304
305 template <class PosT>
306 inline decltype(auto) PosFromVPos<PosT>::make(const VPosBase* a)
307 {
308 return PosT(a->vval());
309 }
310
311 template <class PosT1, class PosT2>
312 inline decltype(auto) PosFromVPos<MPos<PosT1,PosT2>>::make(const VPosBase* a)
313 {
314#if CXZ_DEBUG
315 CXZ_ASSERT(a->vnext() != nullptr, "VPos does not match required size");
316#endif
318 }
319}
320
321#endif
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
constexpr const NPosT & next() const
virtual SizeT vval() const =0
virtual const VPosBase * vnext() const =0
virtual SizeT vval() const override final
VPosRef(const PosT *c)
virtual Uptr< VPosBase > vexec(const VPosBase *a) const override final
virtual Uptr< VPosBase > vplus(const VPosBase *a) const override final
virtual Uptr< VPosBase > vtimes(const VPosBase *a) const override final
virtual const VPosBase * vget() const override final
virtual SizeT vsize() const override final
virtual Uptr< VPosBase > copy() const override final
virtual const VPosBase * vnext() const override final
virtual const VPosBase * vget() const override final
virtual Uptr< VPosBase > vtimes(const VPosBase *a) const override final
virtual Uptr< VPosBase > vplus(const VPosBase *a) const override final
virtual SizeT vval() const override final
VPos(const PosT &a)
virtual Uptr< VPosBase > copy() const override final
virtual Uptr< VPosBase > vexec(const VPosBase *a) const override final
virtual SizeT vsize() const override final
virtual const VPosBase * vnext() const override final
#define IS_NOT_SAME(a, b)
Definition macros.h:122
uint64_t SizeT
Definition types.h:38
std::unique_ptr< T > Uptr
Definition types.h:54
Sptr< Range > rangeCast(const RangePtr r)
Position types declarations.
Dynamic position types declarations.