CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
index_base.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_index_base_h__
13#define __cxz_index_base_h__
14
15#include "base/base.h"
16#include "range_base.h"
17#include "xpr/index_id.h"
18#include "xpr/xpr_base.h"
19#include "xpr/func.h"
20
21namespace CNORXZ
22{
46 template <class I, typename MetaType>
48 {
49 public:
51 ~IndexInterface() = default;
52
54 I& THIS() { return static_cast<I&>(*this); }
55
57 const I& THIS() const { return static_cast<const I&>(*this); }
58
60 I& operator++() { return ++THIS(); }
61
63 I& operator--() { return --THIS();}
64
68 I operator+(Int n) const { return THIS() + n; }
69
73 I operator-(Int n) const { return THIS() - n; }
74
78 I& operator+=(Int n) { return THIS() += n; }
79
83 I& operator-=(Int n) { return THIS() -= n; }
84
88 Int operator-(const IndexInterface& i) const { return lex() - i.lex(); }
89
91 SizeT pos() const;
92
94 SizeT lex() const { return THIS().lex(); }
95
97 SizeT pmax() const { return static_cast<SizeT>(THIS().pmax()); }
98
100 SizeT lmax() const { return static_cast<SizeT>(THIS().lmax()); }
101
102 PtrId ptrId() const;
103
105 decltype(auto) id() const { return THIS().id(); }
106
110 bool operator==(const IndexInterface& i) const;
111
115 bool operator!=(const IndexInterface& i) const;
116
120 bool operator<(const IndexInterface& i) const;
121
125 bool operator>(const IndexInterface& i) const;
126
130 bool operator<=(const IndexInterface& i) const;
131
135 bool operator>=(const IndexInterface& i) const;
136
138 decltype(auto) operator*() const { return THIS().operator*(); }
139
141 SizeT dim() const { return THIS().dim(); }
142
144 decltype(auto) range() const { return THIS().range(); }
145
151 template <SizeT J>
152 decltype(auto) stepSize(const IndexId<J>& id) const { return THIS().stepSize(id); }
153
155 String stringMeta() const { return THIS().stringMeta(); }
156
158 decltype(auto) meta() const { return THIS().meta(); }
159
164 I& at(const MetaType& meta) { return THIS().at(meta); }
165
170 RangePtr prange(const IndexInterface& end) const { return THIS().prange(end.THIS()); }
171
173 decltype(auto) deepFormat() const { return THIS().deepFormat(); }
174
176 decltype(auto) deepMax() const { return THIS().deepMax(); }
177
182 I& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s) { return THIS().reformat(f,s); }
183
191 template <class Xpr, class F = NoF>
192 decltype(auto) ifor(const Xpr& xpr, F&& f) const
193 { return THIS().ifor(xpr,std::forward<F>(f)); }
194
196 bool formatIsTrivial() const { return THIS().formatIsTrivial(); }
197
198 protected:
201 private:
202 friend I; // not protected; I should really be something that is derived from IndexInterface
203
204 // NO DEFAULT CONSTRUCTORS/ASSIGNMENTS!
207 IndexInterface& operator=(const IndexInterface& in);
209 IndexInterface& operator=(IndexInterface&& in);
211
212 PtrId mPtrId = 0;
213 };
214
215
216 template <class I, typename MetaType>
218
219 template <class I, typename MetaType>
221
222 // to define relative indices:
223 template <class I, typename MetaType>
225
226 template <class I, typename MetaType>
228
229 template <class I>
230 Sptr<I> moveToPtr(I&& i);
231
232 template <class I>
233 decltype(auto) xpr(const Sptr<I>& i);
234
235}
236
237#endif
basic headers
decltype(auto) meta() const
Definition index_base.h:158
SizeT pmax() const
Definition index_base.h:97
Int operator-(const IndexInterface &i) const
Definition index_base.h:88
RangePtr prange(const IndexInterface &end) const
Definition index_base.h:170
bool operator<(const IndexInterface &i) const
const I & THIS() const
Definition index_base.h:57
I operator-(Int n) const
Definition index_base.h:73
I & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition index_base.h:182
bool formatIsTrivial() const
Definition index_base.h:196
String stringMeta() const
Definition index_base.h:155
bool operator!=(const IndexInterface &i) const
I operator+(Int n) const
Definition index_base.h:68
decltype(auto) deepFormat() const
Definition index_base.h:173
decltype(auto) ifor(const Xpr &xpr, F &&f) const
Definition index_base.h:192
decltype(auto) range() const
Definition index_base.h:144
bool operator>=(const IndexInterface &i) const
bool operator>(const IndexInterface &i) const
decltype(auto) stepSize(const IndexId< J > &id) const
Definition index_base.h:152
decltype(auto) deepMax() const
Definition index_base.h:176
SizeT lex() const
Definition index_base.h:94
bool operator==(const IndexInterface &i) const
bool operator<=(const IndexInterface &i) const
I & at(const MetaType &meta)
Definition index_base.h:164
Special function objects declarations.
Index ID type declarations.
std::intptr_t PtrId
Definition types.h:35
std::string String
Definition types.h:42
constexpr decltype(auto) operator+(const COpInterface< Op1 > &op1, const COpInterface< Op2 > &op2)
Sptr< I > moveToPtr(I &&i)
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
IndexPtr< I, MetaType > & operator--(const IndexPtr< I, MetaType > &i)
std::vector< T, Allocator< T > > Vector
Definition types.h:310
constexpr decltype(auto) operator-(const COpInterface< Op > &op)
int32_t Int
Definition types.h:36
IndexPtr< I, MetaType > & operator++(const IndexPtr< I, MetaType > &i)
decltype(auto) xpr(const Sptr< I > &i)
Sptr< Range > rangeCast(const RangePtr r)
Sptr< IndexInterface< I, MetaType > > IndexPtr
Definition types.h:164
std::shared_ptr< T > Sptr
Definition types.h:48
RangeBase declaration.
Xpression base declarations.