CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
range_base.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_range_base_cc_h__
13#define __cxz_range_base_cc_h__
14
15#include "range_base.h"
16#include "dindex.h"
17#include "mrange.h"
18
19namespace CNORXZ
20{
21
22 template <class Range>
23 decltype(auto) RangeInterface<Range>::begin() const
24 {
25 typedef typename Range::IndexType IndexType;
26 return IndexType(RangePtr(RB::mThis), 0);
27 }
28
29 template <class Range>
30 decltype(auto) RangeInterface<Range>::end() const
31 {
32 typedef typename Range::IndexType IndexType;
33 return IndexType(RangePtr(RB::mThis), this->size());
34 }
35
36 template <class Range>
38 {
39 typedef typename Range::IndexType IndexType;
40 typedef typename IndexType::MetaType MetaType;
41 return XIndexPtr(std::make_shared<XIndex<IndexType,MetaType>>( this->begin()+pos ));
42 }
43
44 template <class Range>
46 {
47 CXZ_ERROR("cast from '" << r->type().name() << "' to '"
48 << typeid(Range).name() << "' not available");
49 return nullptr;
50 }
51
52 template <class Range>
54 {
55 if(typeid(Range) == r->type()) {
56 return std::dynamic_pointer_cast<Range>(r);
57 }
58 else {
59 return RangeCast<Range>::func(r);
60 }
61 }
62
63}
64
65#endif
#define CXZ_ERROR(errmsg)
Definition assert.h:26
virtual DIndex index(SizeT pos) const override final
Dynamic index declaration.
MRange, GMIndex and MIndex declaration.
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
Sptr< XIndexBase > XIndexPtr
Definition types.h:216
Sptr< Range > rangeCast(const RangePtr r)
std::shared_ptr< T > Sptr
Definition types.h:48
RangeBase declaration.
static Sptr< Range > func(const RangePtr &r)