diff --git a/src/include/ranges/urange.cc.h b/src/include/ranges/urange.cc.h index 40e51ae..8c20c14 100644 --- a/src/include/ranges/urange.cc.h +++ b/src/include/ranges/urange.cc.h @@ -393,7 +393,19 @@ namespace CNORXZ static inline Sptr> cast(const RangePtr& r) { static_assert(std::is_fundamental::value, "got non-fundamental type"); - CXZ_ASSERT(r->dim() == 1, "range cast into URange: source range must have dim = 1, got " << r->dim()); + if constexpr(std::is_same::value){ + if(r->dim() > 1){ + Vector v(r->size()); + for(SizeT i = 0; i != v.size(); ++i) { + v[i] = i; + } + return std::dynamic_pointer_cast> + ( URangeFactory(std::move(v)).create() ); + } + } + else { + CXZ_ASSERT(r->dim() == 1, "range cast into URange: source range must have dim = 1, got " << r->dim()); + } Sptr> o = nullptr; // TODO: cast from CRange!!! o = transform(r); if(o) return o;