CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
xpr_base.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_xpr_base_h__
13#define __cxz_xpr_base_h__
14
15#include "base/base.h"
16#include "pos_type.h"
17#include "index_id.h"
18
19namespace CNORXZ
20{
21
22 template <class Xpr>
24 {
25 public:
27
28 inline Xpr& THIS() { return static_cast<Xpr&>(*this); }
29 inline const Xpr& THIS() const { return static_cast<const Xpr&>(*this); }
30
31 template <class PosT>
32 constexpr decltype(auto) operator()(const PosT& last) const { return THIS()(last); }
33
34 constexpr decltype(auto) operator()() const { return THIS()(); }
35
36 template <SizeT I>
37 constexpr decltype(auto) rootSteps(const IndexId<I>& id) const { return THIS().rootSteps(id); }
38 };
39
40 template <typename T>
42 {
43 public:
45 virtual ~VXprBase() = default;
46
47 virtual Uptr<VXprBase<T>> copy() const = 0;
48
49 virtual T vexec(const DPos& last) const = 0;
50 virtual T vexec() const = 0;
51
52 virtual DPos vrootSteps(const IndexId<0>& id) const = 0;
53 };
54
55 template <typename T, class Xpr>
56 class VXpr : public VXprBase<T>, public Xpr
57 {
58 public:
60 VXpr(const XprInterface<Xpr>& a);
61
63
66
68 };
69
73 {
74 public:
76
78
79 template <class Xpr>
80 explicit DXpr(const Xpr& a);
81
82 inline T operator()(const DPos& last) const;
83 inline T operator()() const;
84
85 template <SizeT I>
86 inline DPos rootSteps(const IndexId<I>& id) const;
87 };
88
89 template <class X>
90 struct is_xpr
91 {
92 static constexpr bool value = std::is_base_of<XprInterface<X>,X>::value;
93 };
94}
95
96#endif
basic headers
DEFAULT_MEMBERS(DXpr)
ObjHandle< VXprBase< T > > VB
Definition xpr_base.h:75
virtual ~VXprBase()=default
virtual Uptr< VXprBase< T > > copy() const =0
DEFAULT_MEMBERS(VXprBase)
virtual DPos vrootSteps(const IndexId< 0 > &id) const =0
virtual T vexec(const DPos &last) const =0
virtual T vexec() const =0
virtual T vexec() const override final
Definition xpr_base.cc.h:42
virtual Uptr< VXprBase< T > > copy() const override final
Definition xpr_base.cc.h:30
virtual DPos vrootSteps(const IndexId< 0 > &id) const override final
Definition xpr_base.cc.h:48
DEFAULT_MEMBERS(VXpr)
VXpr(const XprInterface< Xpr > &a)
Definition xpr_base.cc.h:25
const Xpr & THIS() const
Definition xpr_base.h:29
DEFAULT_MEMBERS(XprInterface)
constexpr decltype(auto) rootSteps(const IndexId< I > &id) const
Definition xpr_base.h:37
Index ID type declarations.
std::unique_ptr< T > Uptr
Definition types.h:54
Sptr< Range > rangeCast(const RangePtr r)
Position types declarations.