EFor: F argument
This commit is contained in:
parent
e9fde3d900
commit
52517675a5
3 changed files with 38 additions and 17 deletions
|
@ -19,8 +19,7 @@ namespace CNORXZ
|
|||
template <class Xpr, class F>
|
||||
decltype(auto) EIndex<MetaT,S>::ifor(const Xpr& xpr, F&& f) const
|
||||
{
|
||||
// TODO: EFor Function argument; meanwhile ignore unused function error!!!
|
||||
return EFor<S,0,Xpr>(this->id(), xpr);
|
||||
return EFor<S,0,Xpr>(this->id(), xpr, std::forward<F>(f));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -389,31 +389,52 @@ namespace CNORXZ
|
|||
* EFor *
|
||||
************/
|
||||
|
||||
template <SizeT N, SizeT L, class Xpr>
|
||||
constexpr EFor<N,L,Xpr>::EFor(const IndexId<L>& id, const Xpr& xpr) :
|
||||
template <SizeT N, SizeT L, class Xpr, class F>
|
||||
constexpr EFor<N,L,Xpr,F>::EFor(const IndexId<L>& id, const Xpr& xpr, F&& f) :
|
||||
mId(id),
|
||||
mXpr(xpr),
|
||||
mExt(mXpr.RootSteps(mId))
|
||||
mExt(mXpr.RootSteps(mId)),
|
||||
mF(std::forward<F>(f))
|
||||
{}
|
||||
|
||||
template <SizeT N, SizeT L, class Xpr>
|
||||
template <SizeT N, SizeT L, class Xpr, class F>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) EFor<N,L,Xpr>::operator()(const PosT& last) const
|
||||
constexpr decltype(auto) EFor<N,L,Xpr,F>::operator()(const PosT& last) const
|
||||
{
|
||||
auto pos = mkEPos<N>(last, mExt);
|
||||
return mXpr(pos);
|
||||
if constexpr(std::is_same<typename std::remove_reference<F>::type,NoF>::value){
|
||||
const auto pos = mkEPos<N>(last, mExt);
|
||||
mXpr(pos);
|
||||
}
|
||||
else {
|
||||
typedef typename
|
||||
std::remove_reference<decltype(mXpr(mkEPos<N>(SPos<0>(), mExt)))>::type OutT;
|
||||
auto o = OutT();
|
||||
const auto pos = mkEPos<N>(last, mExt);
|
||||
mF(o, mXpr(pos));
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
template <SizeT N, SizeT L, class Xpr>
|
||||
constexpr decltype(auto) EFor<N,L,Xpr>::operator()() const
|
||||
template <SizeT N, SizeT L, class Xpr, class F>
|
||||
constexpr decltype(auto) EFor<N,L,Xpr,F>::operator()() const
|
||||
{
|
||||
auto pos = mkEPos<N>(SPos<0>(), mExt);
|
||||
return mXpr(pos);
|
||||
if constexpr(std::is_same<typename std::remove_reference<F>::type,NoF>::value){
|
||||
const auto pos = mkEPos<N>(SPos<0>(), mExt);
|
||||
mXpr(pos);
|
||||
}
|
||||
else {
|
||||
typedef typename
|
||||
std::remove_reference<decltype(mXpr(mkEPos<N>(SPos<0>(), mExt)))>::type OutT;
|
||||
auto o = OutT();
|
||||
const auto pos = mkEPos<N>(SPos<0>(), mExt);
|
||||
mF(o, mXpr(pos));
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
template <SizeT N, SizeT L, class Xpr>
|
||||
template <SizeT N, SizeT L, class Xpr, class F>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) EFor<N,L,Xpr>::rootSteps(const IndexId<I>& id) const
|
||||
constexpr decltype(auto) EFor<N,L,Xpr,F>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
return mXpr.rootSteps(id);
|
||||
}
|
||||
|
|
|
@ -149,13 +149,13 @@ namespace CNORXZ
|
|||
};
|
||||
|
||||
// Extension For (Vectorization)
|
||||
template <SizeT N, SizeT L, class Xpr>
|
||||
template <SizeT N, SizeT L, class Xpr, class F = NoF>
|
||||
class EFor : public XprInterface<EFor<N,L,Xpr>>
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(EFor);
|
||||
|
||||
constexpr EFor(const IndexId<L>& id, const Xpr& xpr);
|
||||
constexpr EFor(const IndexId<L>& id, const Xpr& xpr, F&& f);
|
||||
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& last) const;
|
||||
|
@ -170,6 +170,7 @@ namespace CNORXZ
|
|||
Xpr mXpr;
|
||||
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
||||
XPosT mExt;
|
||||
F mF;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue