CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
index_base.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_index_base_cc_h__
13#define __cxz_index_base_cc_h__
14
15#include "index_base.h"
16
17namespace CNORXZ
18{
19 /*====================+
20 | IndexInterface |
21 +====================*/
22
23 template <class I, typename MetaType>
24 IndexInterface<I,MetaType>::IndexInterface()
25 {
26 mPtrId = reinterpret_cast<PtrId>(this);
27 }
28
29 template <class I, typename MetaType>
30 IndexInterface<I,MetaType>::IndexInterface(const IndexInterface& in) :
31 mPos(in.mPos)
32 {
33 mPtrId = reinterpret_cast<PtrId>(this);
34 }
35
36 template <class I, typename MetaType>
37 IndexInterface<I,MetaType>::IndexInterface(IndexInterface&& in) :
38 mPos(in.mPos)
39 {
40 mPtrId = reinterpret_cast<PtrId>(this);
41 }
42
43 template <class I, typename MetaType>
44 IndexInterface<I,MetaType>& IndexInterface<I,MetaType>::operator=(const IndexInterface& in)
45 {
46 mPos = in.mPos;
47 return *this;
48 }
49
50 template <class I, typename MetaType>
51 IndexInterface<I,MetaType>& IndexInterface<I,MetaType>::operator=(IndexInterface&& in)
52 {
53 mPos = in.mPos;
54 return *this;
55 }
56
57 template <class I, typename MetaType>
58 IndexInterface<I,MetaType>::IndexInterface(SizeT pos) :
59 mPos(pos)
60 {
61 mPtrId = reinterpret_cast<PtrId>(this);
62 }
63
64 template <class I, typename MetaType>
66 {
67 return in.lex() == lex() and *in.range() == *range();
68 }
69
70 template <class I, typename MetaType>
72 {
73 return in.lex() != lex() or *in.range() != *range();
74 }
75
76 template <class I, typename MetaType>
78 {
79 return lex() < in.lex();
80 }
81
82 template <class I, typename MetaType>
84 {
85 return lex() > in.lex();
86 }
87
88 template <class I, typename MetaType>
90 {
91 return lex() <= in.lex();
92 }
93
94 template <class I, typename MetaType>
96 {
97 return lex() >= in.lex();
98 }
99
100 template <class I, typename MetaType>
103 return mPos;
104 }
105
106 template <class I, typename MetaType>
108 {
109 // if this assert never applies, remove mPtrId (-> Defaults) !!!
110 assert(mPtrId == reinterpret_cast<PtrId>(this));
111 return mPtrId;
112 }
113
114
115 /*==========================+
116 | Non-member functions |
117 +==========================*/
118
119 template <class I, typename MetaType>
121 {
122 ++(*i);
123 return i;
124 }
126 template <class I, typename MetaType>
128 {
129 --(*i);
130 return i;
131 }
132
133 template <class I, typename MetaType>
136 return std::make_shared<IndexInterface<I,MetaType>>( *i + n );
137 }
138
139 template <class I, typename MetaType>
141 {
142 return std::make_shared<IndexInterface<I,MetaType>>( *i - n );
143 }
144
145 template <class I>
147 {
148 return std::make_shared<I>(std::forward<I>(i));
149 }
150
151 template <class I>
152 decltype(auto) xpr(const Sptr<I>& i)
153 {
154 static_assert(is_index<I>::value, "got non-index type");
155 static_assert(index_expression_exists<I>::value, "expression for given index type does not exist");
156 return i->xpr(i);
157 }
158
159}
160
161#endif
decltype(auto) range() const
Definition index_base.h:144
SizeT lex() const
Definition index_base.h:94
Index base declaration.
std::intptr_t PtrId
Definition types.h:35
constexpr decltype(auto) operator+(const COpInterface< Op1 > &op1, const COpInterface< Op2 > &op2)
Sptr< I > moveToPtr(I &&i)
uint64_t SizeT
Definition types.h:38
IndexPtr< I, MetaType > & operator--(const IndexPtr< I, MetaType > &i)
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