diff --git a/src/include/array/array_base.h b/src/include/array/array_base.h index 0e187d6..97e48a7 100644 --- a/src/include/array/array_base.h +++ b/src/include/array/array_base.h @@ -45,6 +45,9 @@ namespace CNORXZ /** default destructor */ virtual ~CArrayBase() = default; + /** Return unique pointer copy of itself. */ + virtual Uptr copy() const = 0; + /** const data element access. If the array's format is trivial or the index is already non-trivially formatted, this is equivalent to data()[i.pos()]. Otherwise, the array's format is applied. diff --git a/src/include/array/marray.cc.h b/src/include/array/marray.cc.h index d60b07d..d18391c 100644 --- a/src/include/array/marray.cc.h +++ b/src/include/array/marray.cc.h @@ -61,6 +61,12 @@ namespace CNORXZ return *this; } + template + Uptr> MArray::copy() const + { + return std::make_unique>(*this); + } + template const T* MArray::data() const { diff --git a/src/include/array/marray.h b/src/include/array/marray.h index 384cacb..779f77b 100644 --- a/src/include/array/marray.h +++ b/src/include/array/marray.h @@ -38,6 +38,7 @@ namespace CNORXZ MArray& init(const RangePtr& range); MArray& extend(const RangePtr& range); + virtual Uptr> copy() const override; virtual const T* data() const override; virtual T* data() override; virtual const_iterator cbegin() const override; diff --git a/src/include/array/slice.cc.h b/src/include/array/slice.cc.h index 95131b9..6d022f2 100644 --- a/src/include/array/slice.cc.h +++ b/src/include/array/slice.cc.h @@ -29,6 +29,12 @@ namespace CNORXZ mOff(off) {} + template + Uptr> CSlice::copy() const + { + return std::make_unique>(*this); + } + template const T* CSlice::data() const { @@ -76,6 +82,12 @@ namespace CNORXZ mOff(off) {} + template + Uptr> Slice::copy() const + { + return std::make_unique>(*this); + } + template T* Slice::data() { diff --git a/src/include/array/slice.h b/src/include/array/slice.h index fab06da..6acb184 100644 --- a/src/include/array/slice.h +++ b/src/include/array/slice.h @@ -41,7 +41,8 @@ namespace CNORXZ */ CSlice(const RangePtr& range, const CArrayBase* parent, const YFormat& blockSizes, SizeT off); - + + virtual Uptr> copy() const override; virtual const T* data() const override; virtual const_iterator cbegin() const override; virtual const_iterator cend() const override; @@ -82,6 +83,7 @@ namespace CNORXZ Slice(const RangePtr& range, ArrayBase* parent, const YFormat& blockSizes, SizeT off); + virtual Uptr> copy() const override; virtual const T* data() const override; virtual T* data() override; virtual const_iterator cbegin() const override; diff --git a/src/opt/mpi/include/rrange.h b/src/opt/mpi/include/rrange.h index a95d192..2f636cf 100644 --- a/src/opt/mpi/include/rrange.h +++ b/src/opt/mpi/include/rrange.h @@ -152,13 +152,13 @@ namespace CNORXZ template struct is_rank_index { - constexpr bool value = false; + static constexpr bool value = false; }; template - struct is_rank_index + struct is_rank_index> { - constexpr bool value = true; + static constexpr bool value = true; }; /** ****