yrange()/mrange(): add xpl version

This commit is contained in:
Christian Zimmermann 2024-03-13 19:10:04 +01:00
parent 21a2ca0b72
commit af47dd01f9
5 changed files with 24 additions and 1 deletions

View file

@ -808,6 +808,12 @@ namespace CNORXZ
return MRangeFactory<Ranges...>(std::make_tuple(rs...)).create();
}
template <class... Ranges>
Sptr<MRange<Ranges...>> xplMrange(const Sptr<Ranges>&... rs)
{
return std::dynamic_pointer_cast<MRange<Ranges...>>( mrange( rs... ) );
}
template <class... Ranges>
Sptr<MRange<Ranges...>> RangeCast<MRange<Ranges...>>::func(const RangePtr& r)
{

View file

@ -405,6 +405,12 @@ namespace CNORXZ
template <class... Ranges>
RangePtr mrange(const Sptr<Ranges>&... rs);
/** Create MRange pointer.
@param rs Pointer to sub-ranges.
*/
template <class... Ranges>
Sptr<MRange<Ranges...>> xplMrange(const Sptr<Ranges>&... rs);
/** ****
Specialization of RangeCast for MRange.
@see RangeCast.

View file

@ -343,6 +343,12 @@ namespace CNORXZ
*/
RangePtr yrange(const Vector<RangePtr>& rs);
/** Create YRange from sub-ranges.
@param rs Vector of pointers to the sub-ranges used by the YRange.
@return A shared pointer to the created YRange.
*/
Sptr<YRange> xplYrange(const Vector<RangePtr>& rs);
/** ****
Specialize RangeCast for casts to YRange.
@see RangeCast

View file

@ -668,6 +668,11 @@ namespace CNORXZ
return YRangeFactory(rs).create();
}
Sptr<YRange> xplYrange(const Vector<RangePtr>& rs)
{
return std::dynamic_pointer_cast<YRange>( yrange( rs ) );
}
/*=================+
| Range Casts |
+=================*/

View file

@ -441,7 +441,7 @@ namespace CNORXZ
auto mr = ifor<0,N>( [&](auto mu) {
return split( global->space()[CSizeT<mu>{}], geom->space()[CSizeT<mu>{}] );
}, [](const auto&... r) { return xplMrange(r,...); } );
typedef std::remove_reference<decltype(mr)>::type RangeI;
typedef std::remove_reference<decltype(*mr)>::type RangeI;
return RRangeFactory<RangeI,RangeK>(mr, geom).create(); // explicit range type!!!
}
// other cases!!!