diff --git a/src/include/ranges/single_range.h b/src/include/ranges/single_range.h index 7a4c0b9..30954b2 100644 --- a/src/include/ranges/single_range.h +++ b/src/include/ranges/single_range.h @@ -139,7 +139,7 @@ namespace MultiArrayTools ******************/ template - struct MetaPtrSetter + struct MetaPtrHandle { template static const typename Range::MetaType* set(Range* r) @@ -147,22 +147,33 @@ namespace MultiArrayTools return &r->get(0); } + template + static inline U getMeta(U* metaPtr, size_t pos, std::shared_ptr r) + { + return metaPtr[pos]; + } }; template <> - struct MetaPtrSetter + struct MetaPtrHandle { template static const typename Range::MetaType* set(Range* r) { return nullptr; } + + template + static inline U getMeta(U* metaPtr, size_t pos, std::shared_ptr r) + { + return r->get(pos); + } }; template SingleIndex::SingleIndex(const std::shared_ptr >& range) : IndexInterface,U>(range, 0), - mMetaPtr(MetaPtrSetter::RangeType::HASMETACONT>::set + mMetaPtr(MetaPtrHandle::RangeType::HASMETACONT>::set ( dynamic_cast(IB::mRangePtr.get() ) ) ) {} template @@ -209,7 +220,9 @@ namespace MultiArrayTools template U SingleIndex::meta() { - return mMetaPtr[IB::mPos]; + return MetaPtrHandle::RangeType::HASMETACONT>::getMeta + ( mMetaPtr, IB::mPos, + std::dynamic_pointer_cast const>( IB::mRangePtr ) ); } template