From 87a699a445f881aff821f9736bd2453d6e9c9ff0 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 12 Feb 2018 18:26:56 +0100 Subject: [PATCH] im com; TODO: rootSteps, mkOpExpr --- src/multi_array_operation.h | 24 ++++++++++++------------ src/pack_num.h | 19 ++++++++----------- src/xfor/exttype.h | 8 ++++---- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index 1cf1f72..a46fcdb 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -108,7 +108,7 @@ namespace MultiArrayTools inline void operator()(size_t start = 0); inline void operator()(size_t start, ExtType last); - auto rootSteps(std::intptr_t iPtrNum = 0) -> ExtType; + auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; }; @@ -170,7 +170,7 @@ namespace MultiArrayTools const Block& get() const; - template + template inline const T& get(const ET& pos) const; std::vector block(const IndexInfo* blockIndex, bool init = false) const; @@ -218,10 +218,10 @@ namespace MultiArrayTools const MBlock& get() const; MBlock& get(); - template + template inline const T& get(const ET& pos) const; - template + template inline T& get(const ET& pos); OperationRoot& set(const IndexInfo* blockIndex); @@ -363,7 +363,7 @@ namespace MultiArrayTools -> decltype(mOp.rootSteps(iPtrNum)); template - auto loop(Expr&& exp) const -> decltype(mInd->iforh(exp))&&; + auto loop(Expr exp) const -> decltype(mInd->iforh(exp)); }; } @@ -497,7 +497,7 @@ namespace MultiArrayTools template typename OperationMaster::AssignmentExpr::ExtType OperationMaster::AssignmentExpr:: - rootSteps(std::intptr_t iPtrNum) + rootSteps(std::intptr_t iPtrNum) const { return mSec.rootSteps(iPtrNum); } @@ -650,10 +650,10 @@ namespace MultiArrayTools } template - template + template inline const T& ConstOperationRoot::get(const ET& pos) const { - return mData[std::get(pos)]; + return mData[pos.val()]; } template @@ -739,17 +739,17 @@ namespace MultiArrayTools } template - template + template inline const T& OperationRoot::get(const ET& pos) const { - return mData[std::get( pos )]; + return mData[pos.val()]; } template - template + template inline T& OperationRoot::get(const ET& pos) { - return mData[std::get( pos )]; + return mData[pos.val()]; } template diff --git a/src/pack_num.h b/src/pack_num.h index e0cc991..4cb5f5a 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -9,6 +9,7 @@ #include #include "base_def.h" +#include "xfor/exttype.h" namespace MultiArrayHelper { @@ -67,14 +68,12 @@ namespace MultiArrayHelper } // call with -2 (instead of -1) - template - static T mkOpExpr(const ETuple& pos, const OpTuple& ops) + template + static inline T mkOpExpr(const ETuple& pos, const OpTuple& ops, const Args&... args) { - typedef typename std::tuple_element::type SubOpTypeRef; - typedef typename std::remove_reference::type SubOpType; - static const size_t NEXT = START - SubOpType::SIZE; - return OpFunction::apply( std::get(ops).template get(pos), - PackNum::template mkOpExpr(pos, ops) ); + + return PackNum::template mkOpExpr(ops)),Args...> + ( pos, ops, std::get(ops).get(Getter<>::template get( pos )), args...); } template @@ -138,11 +137,9 @@ namespace MultiArrayHelper } template - static T mkOpExpr(const ETuple& pos, const OpTuple& ops) + static inline T mkOpExpr(const ETuple& pos, const OpTuple& ops) { - typedef typename std::tuple_element<1,OpTuple>::type SubOpTypeRef; - typedef typename std::remove_reference::type SubOpType; - static const size_t NEXT = START - SubOpType::SIZE; + static constexpr size_t NEXT = START - SubOpType::SIZE; return OpFunction::apply( std::get<1>(ops).template get(pos), std::get<0>(ops).template get(pos) ); } diff --git a/src/xfor/exttype.h b/src/xfor/exttype.h index 15ddb5b..10dd4f9 100644 --- a/src/xfor/exttype.h +++ b/src/xfor/exttype.h @@ -4,7 +4,7 @@ #include -namespace XFOR +namespace MultiArrayHelper { template @@ -102,13 +102,13 @@ namespace XFOR } }; -} // end namespace XFOR +} // end namespace MultiArrayHelper /* ========================= * * --- TEMPLATE CODE --- * * ========================= */ -namespace XFOR +namespace MultiArrayHelper { template @@ -172,7 +172,7 @@ namespace XFOR } -} // end namespace XFOR +} // end namespace MultiArrayHelper #endif