#ifndef __cxz_array_base_h__ #define __cxz_array_base_h__ #include #include #include #include #include "base/base.h" #include "aindex.h" //#include "operation/" namespace CNORXZ { template class CArrayBase { public: typedef AIndex const_iterator; protected: RangePtr mRange; public: CArrayBase(const RangePtr& range); DEFAULT_MEMBERS(CArrayBase); virtual ~CArrayBase() = default; template const T& operator[](const IndexInterface& i) const; template const T& at(const IndexInterface& i) const; template Sptr> sl(const IndexInterface& i) const; virtual const T* data() const = 0; virtual SizeT size() const; virtual RangePtr range() const; virtual const_iterator begin() const; virtual const_iterator end() const; virtual const_iterator cbegin() const = 0; virtual const_iterator cend() const = 0; virtual bool isView() const = 0; //template //ConstOperationRoot operator()(const IndexPtr& i) const; }; template class ArrayBase : public CArrayBase { public: typedef CArrayBase CAB; typedef typename CAB::const_iterator const_iterator; typedef BIndex iterator; using CAB::operator[]; using CAB::at; using CAB::data; using CAB::begin; using CAB::end; using CAB::cbegin; using CAB::cend; //using CAB::operator(); ArrayBase(const RangePtr& range); DEFAULT_MEMBERS(ArrayBase); template T& operator[](const IndexInterface& i); template T& at(const IndexInterface& i); template Sptr> sl(const IndexInterface& i); virtual T* data() = 0; virtual iterator begin(); virtual iterator end(); //template //OperationRoot operator()(const IndexPtr& i); }; // to extra header file !!!: template constexpr decltype(auto) flattenIndexPack(const Tuple...>& ipack) { constexpr SizeT D = sizeof...(Indices); } inline Vector flattenIndexPack(const Vector& ipack) { } template inline SizeT indexPackDim(Tuple...> ipack) { constexpr SizeT D = sizeof...(Indices); return iter<0,D>([&](const auto& i) { return std::get(ipack)->dim(); }, [](const auto&... e) { return (e + ...); }); } inline SizeT indexPackDim(const Vector& ipack) { return std::accumulate(ipack.begin(), ipack.end(), ipack[0]->dim(), [](auto a, auto b) { return a->dim() + b->dim(); }); } } #endif