This commit is contained in:
Christian Zimmermann 2018-08-05 18:45:20 +02:00
parent 6d52a6cdd9
commit 65d907df15
2 changed files with 26 additions and 2 deletions

View file

@ -44,6 +44,10 @@ namespace MultiArrayTools
template <class Range>
auto createRange(const std::vector<char>& cvec)
-> std::shared_ptr<Range>;
template <size_t N, class MArray>
auto prtr(const MArray& ma)
-> decltype(ma.template getRangePtr<N>());
}
/* ========================= *
@ -128,6 +132,13 @@ namespace MultiArrayTools
return std::dynamic_pointer_cast<Range>( rbptr );
}
template <size_t N, class MArray>
auto rptr(const MArray& ma)
-> decltype(ma.template getRangePtr<N>())
{
return ma.template getRangePtr<N>();
}
}
#endif

View file

@ -19,6 +19,7 @@ namespace MultiArrayTools
DEFAULT_MEMBERS(ConstSlice);
ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data = nullptr);
ConstSlice(const MultiArray<T,AnonymousRange>& ma, SIZET<SRanges>...);
virtual const T& operator[](const IType& i) const override;
virtual const T& at(const typename IType::MetaType& meta) const override;
@ -130,7 +131,19 @@ namespace MultiArrayTools
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data) :
MultiArrayBase<T,SRanges...>(ranges...),
mData(data) {}
mData(data)
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const MultiArray<T,AnonymousRange>& ma, SIZET<SRanges>...) :
MutableMultiArrayBase<T,SRanges...>
( ma.range()->template get<0>().template scast<SRanges...>(sizes...)->space() ),
mData( ma.data() )
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
const T& ConstSlice<T,SRanges...>::operator[](const IType& i) const