mrange: range cast
This commit is contained in:
parent
abb47cbb06
commit
bea9add008
2 changed files with 17 additions and 0 deletions
|
@ -651,6 +651,17 @@ namespace CNORXZ
|
|||
return MRangeFactory<Ranges...>(std::make_tuple(rs...)).create();
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
Sptr<MRange<Ranges...>> RangeCast<MRange<Ranges...>>::func(const RangePtr& r)
|
||||
{
|
||||
CXZ_ASSERT(r->dim() == sizeof...(Ranges), "expect range of dimension "
|
||||
<< sizeof...(Ranges) << ", got " << r->dim());
|
||||
return std::dynamic_pointer_cast<MRange<Ranges...>>( MRangeFactory
|
||||
( iter<0,sizeof...(Ranges)>
|
||||
( [&](auto i) {
|
||||
return rangeCast<typename std::tuple_element<i,Tuple<Ranges...>>::type> (r->sub(i)); },
|
||||
[](const auto&... e){ return std::make_tuple( e... ); } ) ).create() );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -203,6 +203,12 @@ namespace CNORXZ
|
|||
|
||||
template <class... Ranges>
|
||||
RangePtr mrange(const Sptr<Ranges>&... rs);
|
||||
|
||||
template <class... Ranges>
|
||||
struct RangeCast<MRange<Ranges...>>
|
||||
{
|
||||
static Sptr<MRange<Ranges...>> func(const RangePtr& r);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue