#ifndef __cxz_for_h__ #define __cxz_for_h__ #include "base/base.h" #include "xpr_base.h" namespace CNORXZ { class ZeroF { public: template constexpr decltype(auto) operator()(const T&... as) const; }; class NoF { public: template constexpr decltype(auto) operator()(const T&... as) const; }; template class For : public XprInterface> { public: DEFAULT_MEMBERS(For); constexpr For(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); template inline decltype(auto) operator()(const PosT& last) const; inline decltype(auto) operator()() const; template inline decltype(auto) rootSteps(const IndexId& id) const; private: SizeT mSize = 0; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; F mF; }; // unrolled loop: template class SFor : public XprInterface> { public: DEFAULT_MEMBERS(SFor); constexpr SFor(const IndexId& id, const Xpr& xpr, F&& f); template constexpr decltype(auto) operator()(const PosT& last) const; constexpr decltype(auto) operator()() const; template constexpr decltype(auto) rootSteps(const IndexId& id) const; private: template constexpr decltype(auto) exec(const PosT& last) const; template constexpr decltype(auto) exec() const; IndexId mId; Xpr mXpr; typedef decltype(mXpr.RootSteps(mId)) XPosT; XPosT mExt; F mF; }; // multi-threading template class TFor : public XprInterface> { public: DEFAULT_MEMBERS(TFor); constexpr TFor(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); template inline decltype(auto) operator()(const PosT& last) const; inline decltype(auto) operator()() const; template inline decltype(auto) rootSteps(const IndexId& id) const; private: SizeT mSize = 0; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; F mF; }; // Extension For (Vectorization) template class EFor : public XprInterface> { public: DEFAULT_MEMBERS(EFor); constexpr EFor(const IndexId& id, const Xpr& xpr); template constexpr decltype(auto) operator()(const PosT& last) const; constexpr decltype(auto) operator()() const; template constexpr decltype(auto) rootSteps(const IndexId& id) const; private: IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; }; } #endif