diff --git a/src/include/ranges/eindex.cc.h b/src/include/ranges/eindex.cc.h new file mode 100644 index 0000000..a566125 --- /dev/null +++ b/src/include/ranges/eindex.cc.h @@ -0,0 +1,28 @@ + +#ifndef __cxz_eindex_cc_h__ +#define __cxz_eindex_cc_h__ + +#include "eindex.h" + +namespace CNORXZ +{ + + template + EIndex::EIndex(const SIndex& i) : + SIndex(i) {} + + template + EIndex::EIndex(SIndex&& i) : + SIndex(i) {} + + template + template + decltype(auto) EIndex::ifor(const Xpr& xpr, F&& f) const + { + // TODO: EFor Function argument; meanwhile ignore unused function error!!! + return EFor(this->id(), xpr); + } + +} + +#endif diff --git a/src/include/ranges/eindex.h b/src/include/ranges/eindex.h new file mode 100644 index 0000000..75b498c --- /dev/null +++ b/src/include/ranges/eindex.h @@ -0,0 +1,29 @@ + +#ifndef __cxz_eindex_h__ +#define __cxz_eindex_h__ + +#include "base/base.h" +#include "ranges/index_base.h" +#include "ranges/range_base.h" +#include "xpr/xpr.h" + +namespace CNORXZ +{ + template + class EIndex : public SIndex + { + public: + typedef typename SIndex::IB IB; + typedef typename SIndex::RangeType RangeType; + + DEFAULT_MEMBERS(EIndex); + EIndex(const SIndex& i); + EIndex(SIndex&& i); + + template + decltype(auto) ifor(const Xpr& xpr, F&& f) const; + }; + +} + +#endif diff --git a/src/include/ranges/srange.cc.h b/src/include/ranges/srange.cc.h index e753435..7efd4f9 100644 --- a/src/include/ranges/srange.cc.h +++ b/src/include/ranges/srange.cc.h @@ -289,6 +289,28 @@ namespace CNORXZ return Vector { this->id() }; } + /******************* + * Range Casts * + *******************/ + + template + Sptr> RangeCast>::func(const RangePtr& r) + { + Sptr> tmp; + if(r->type() != typeid(URange)){ + tmp = castRange>(r); + } + else { + tmp = r; + } + CXZ_ASSERT(tmp->size() == S, "cannot cast range of size " << tmp->size() + << " into static range of size " << S); + Arr space; + std::copy(tmp->begin(), tmp->end(), space.begin()); + return std::dynamic_pointer_cast> + ( SRangeFactory(std::move(space)).create() ); + } + } #endif