final at [] + assignment between Container Indices of different data type
This commit is contained in:
parent
ca01dcaa10
commit
be016abf3a
4 changed files with 51 additions and 6 deletions
|
@ -56,8 +56,8 @@ namespace MultiArrayTools
|
||||||
//template <class Range2, class Range3>
|
//template <class Range2, class Range3>
|
||||||
//MultiArray& operator=(const MultiArray<MultiArray<T,Range2>,Range3> in);
|
//MultiArray& operator=(const MultiArray<MultiArray<T,Range2>,Range3> in);
|
||||||
|
|
||||||
virtual T& operator[](const IndexType& i) override;
|
virtual T& operator[](const IndexType& i) final;
|
||||||
virtual const T& operator[](const IndexType& i) const override;
|
virtual const T& operator[](const IndexType& i) const final;
|
||||||
virtual T& at(const typename IndexType::MetaType& meta) override;
|
virtual T& at(const typename IndexType::MetaType& meta) override;
|
||||||
virtual const T& at(const typename IndexType::MetaType& meta) const override;
|
virtual const T& at(const typename IndexType::MetaType& meta) const override;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual ~MultiArrayBase() = default;
|
virtual ~MultiArrayBase() = default;
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
const T& operator[](const ContainerIndex<X,typename SRanges::IndexType...>& i);
|
||||||
|
|
||||||
virtual const T& operator[](const IndexType& i) const = 0;
|
virtual const T& operator[](const IndexType& i) const = 0;
|
||||||
virtual const T& at(const typename CRange::IndexType::MetaType& meta) const = 0;
|
virtual const T& at(const typename CRange::IndexType::MetaType& meta) const = 0;
|
||||||
|
|
||||||
|
@ -95,6 +98,9 @@ namespace MultiArrayTools
|
||||||
DEFAULT_MEMBERS(MutableMultiArrayBase);
|
DEFAULT_MEMBERS(MutableMultiArrayBase);
|
||||||
MutableMultiArrayBase(const std::shared_ptr<SRanges>&... ranges);
|
MutableMultiArrayBase(const std::shared_ptr<SRanges>&... ranges);
|
||||||
MutableMultiArrayBase(const typename CRange::Space& space);
|
MutableMultiArrayBase(const typename CRange::Space& space);
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
T& operator[](const ContainerIndex<X,typename SRanges::IndexType...>& i);
|
||||||
|
|
||||||
virtual T& operator[](const IndexType& i) = 0;
|
virtual T& operator[](const IndexType& i) = 0;
|
||||||
virtual T& at(const typename CRange::IndexType::MetaType& meta) = 0;
|
virtual T& at(const typename CRange::IndexType::MetaType& meta) = 0;
|
||||||
|
@ -158,6 +164,16 @@ namespace MultiArrayTools
|
||||||
mRange = std::dynamic_pointer_cast<ContainerRange<T,SRanges...> >( crf.create() );
|
mRange = std::dynamic_pointer_cast<ContainerRange<T,SRanges...> >( crf.create() );
|
||||||
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
|
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... SRanges>
|
||||||
|
template <typename X>
|
||||||
|
const T& MultiArrayBase<T,SRanges...>::operator[](const ContainerIndex<X,typename SRanges::IndexType...>& i)
|
||||||
|
{
|
||||||
|
IndexType ii(*mProtoI);
|
||||||
|
ii = i;
|
||||||
|
return (*this)[ii];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
size_t MultiArrayBase<T,SRanges...>::size() const
|
size_t MultiArrayBase<T,SRanges...>::size() const
|
||||||
|
@ -279,6 +295,17 @@ namespace MultiArrayTools
|
||||||
return i.setData(data());
|
return i.setData(data());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template <typename T, class... SRanges>
|
||||||
|
template <typename X>
|
||||||
|
T& MutableMultiArrayBase<T,SRanges...>::operator[](const ContainerIndex<X,typename SRanges::IndexType...>& i)
|
||||||
|
{
|
||||||
|
IndexType ii(*MAB::mProtoI);
|
||||||
|
ii = i;
|
||||||
|
return (*this)[ii];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
bool MutableMultiArrayBase<T,SRanges...>::isConst() const
|
bool MutableMultiArrayBase<T,SRanges...>::isConst() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,12 @@ namespace MultiArrayTools
|
||||||
static constexpr size_t totalDim() { return mkTotalDim<Indices...>(); }
|
static constexpr size_t totalDim() { return mkTotalDim<Indices...>(); }
|
||||||
|
|
||||||
static constexpr SpaceType STYPE = SpaceType::ANY;
|
static constexpr SpaceType STYPE = SpaceType::ANY;
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
using CIX = ContainerIndex<X,Indices...>;
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
friend class CIX;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -50,6 +56,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
ContainerIndex(const ContainerIndex& in) = default;
|
ContainerIndex(const ContainerIndex& in) = default;
|
||||||
ContainerIndex& operator=(const ContainerIndex& in) = default;
|
ContainerIndex& operator=(const ContainerIndex& in) = default;
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
ContainerIndex& operator=(const ContainerIndex<X,Indices...>& in);
|
||||||
|
|
||||||
template <class MRange>
|
template <class MRange>
|
||||||
ContainerIndex(const std::shared_ptr<MRange>& range,
|
ContainerIndex(const std::shared_ptr<MRange>& range,
|
||||||
|
@ -251,7 +260,16 @@ namespace MultiArrayTools
|
||||||
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
||||||
mNonTrivialBlocks = true;
|
mNonTrivialBlocks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Indices>
|
||||||
|
template <typename X>
|
||||||
|
ContainerIndex<T,Indices...>&
|
||||||
|
ContainerIndex<T,Indices...>::operator=(const ContainerIndex<X,Indices...>& in)
|
||||||
|
{
|
||||||
|
mIPack = in.mIPack;
|
||||||
|
return (*this)();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
template <typename T, class... Indices>
|
||||||
ContainerIndex<T,Indices...>& ContainerIndex<T,Indices...>::sync()
|
ContainerIndex<T,Indices...>& ContainerIndex<T,Indices...>::sync()
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace MultiArrayTools
|
||||||
ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data = nullptr);
|
ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data = nullptr);
|
||||||
ConstSlice(const MultiArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... sizes);
|
ConstSlice(const MultiArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... sizes);
|
||||||
|
|
||||||
virtual const T& operator[](const IType& i) const override;
|
virtual const T& operator[](const IType& i) const final;
|
||||||
virtual const T& at(const typename IType::MetaType& meta) const override;
|
virtual const T& at(const typename IType::MetaType& meta) const override;
|
||||||
|
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
|
@ -63,8 +63,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
Slice(const std::shared_ptr<SRanges>&... ranges, T* data = nullptr);
|
Slice(const std::shared_ptr<SRanges>&... ranges, T* data = nullptr);
|
||||||
|
|
||||||
virtual const T& operator[](const IType& i) const override;
|
virtual const T& operator[](const IType& i) const final;
|
||||||
virtual T& operator[](const IType& i) override;
|
virtual T& operator[](const IType& i) final;
|
||||||
virtual const T& at(const typename IType::MetaType& meta) const override;
|
virtual const T& at(const typename IType::MetaType& meta) const override;
|
||||||
virtual T& at(const typename IType::MetaType& meta) override;
|
virtual T& at(const typename IType::MetaType& meta) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue