cast to dynmic range array for mutable container
This commit is contained in:
parent
015734fa16
commit
867c6e13e9
2 changed files with 21 additions and 0 deletions
|
@ -169,6 +169,23 @@ namespace MultiArrayTools
|
|||
}
|
||||
}
|
||||
|
||||
template <class EC, class MArray>
|
||||
auto mdynamic(MArray& ma, bool slice)
|
||||
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>
|
||||
{
|
||||
DynamicRangeFactory<EC> drf(ma.range()->space());
|
||||
if(slice){
|
||||
return std::make_shared<Slice<typename MArray::value_type,DynamicRange<EC>>>
|
||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
||||
ma.data() );
|
||||
}
|
||||
else {
|
||||
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange<EC>>>
|
||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
||||
ma.vdata() );
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <size_t N>
|
||||
|
|
|
@ -89,6 +89,10 @@ namespace MultiArrayTools
|
|||
auto dynamic(const MArray& ma, bool slice = false)
|
||||
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>;
|
||||
|
||||
template <class EC, class MArray>
|
||||
auto mdynamic(MArray& ma, bool slice)
|
||||
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>;
|
||||
|
||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
||||
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
||||
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange<EC>>;
|
||||
|
|
Loading…
Reference in a new issue