#ifndef __xfor_h__ #define __xfor_h__ #include #include namespace MultiArrayHelper { template class For { public: For(For&& in) = default; For& operator=(For&& in) = default; template For(const std::shared_ptr& indPtr, const Args&... args); inline void operator()(size_t start = 0); private: For() = default; std::shared_ptr mIndPtr; Expr mExpr; } } // namespace MultiArrayHelper /* ========================= * * --- TEMPLATE CODE --- * * ========================= */ namespace MultiArrayHelper { template template For::For(const std::shared_ptr& indPtr, const Args&... args) : mIndPtr(indPtr), mExpr(args...) {} template inline void For::operator()(size_t start) { auto& ind = *mIndPtr; const size_t max = ind.max(); for(ind = 0; ind.pos() != max; ++ind){ mExpr(start * max + ind.pos()); // CHECK!! } } } // namespace MultiArrayHelper #endif