diff --git a/src/include/dynamic_operation.cc.h b/src/include/dynamic_operation.cc.h index cdd1332..39aa818 100644 --- a/src/include/dynamic_operation.cc.h +++ b/src/include/dynamic_operation.cc.h @@ -6,18 +6,8 @@ namespace MultiArrayTools template const T& DynamicOperation::get(const DExtT& pos) const { - if(pos.isInit()){ - VCHECK(pos.stype()); - ET xx; - VCHECK(xx.stype()); - VCHECK(mOp.rootSteps(0).stype()); - VCHECK(pos.expl().val()); - return mOp.get(pos.expl()); - } - else { - ET xx; - return mOp.get(xx); - } + VCHECK(pos.expl().val()); + return mOp.get(pos.expl()); } template diff --git a/src/include/xfor/exttype.h b/src/include/xfor/exttype.h index e14ee82..ebb84e1 100644 --- a/src/include/xfor/exttype.h +++ b/src/include/xfor/exttype.h @@ -92,10 +92,6 @@ namespace MultiArrayHelper auto extend(const Y& y) const -> MExt { return MExt(mExt, mNext.extend(y)); } - std::string stype() const { return std::string("E[") + mNext.stype() + "]"; } - - const MExt& lowest() const { return *this; } - MExt& lowest() { return *this; } }; struct None @@ -121,11 +117,6 @@ namespace MultiArrayHelper template Y extend(const Y& y) const { return y; } - - std::string stype() const { return "N"; } - - const None& lowest() const { return *this; } - None& lowest() { return *this; } }; template <> @@ -179,10 +170,6 @@ namespace MultiArrayHelper auto extend(const Y& y) const -> MExt { return MExt(mExt,y); } - std::string stype() const { return "E[N]"; } - - const MExt& lowest() const { return *this; } - MExt& lowest() { return *this; } }; diff --git a/src/include/xfor/xfor.h b/src/include/xfor/xfor.h index d32d26e..9beb278 100644 --- a/src/include/xfor/xfor.h +++ b/src/include/xfor/xfor.h @@ -44,8 +44,6 @@ namespace MultiArrayHelper template const ExtType& expl() const; - virtual std::string stype() const = 0; - }; typedef std::shared_ptr DExt; @@ -65,7 +63,7 @@ namespace MultiArrayHelper ExtT& operator=(const ExtT& in) = default; ExtT& operator=(ExtT&& in) = default; - ExtT(const ExtType& in) : mExt(in) { assert(in.stype()[0] != 'T'); } + ExtT(const ExtType& in) : mExt(in) {} virtual std::shared_ptr deepCopy() const override final { return std::make_shared>(mExt); } @@ -80,70 +78,31 @@ namespace MultiArrayHelper { return std::make_shared( mExt + dynamic_cast(in).mExt ); } virtual DExt operator*(size_t in) const override final { return std::make_shared( mExt * in ); } - - virtual std::string stype() const override final { return std::string("T[")+mExt.stype()+"]"; } - const ExtType& lowest() const { return mExt; } - ExtType& lowest() { return mExt; } }; //class DExtT; - template - class DExtTX; - template - struct SptrExtT - { - typedef typename std::remove_reference().lowest())>::type YX; - - static DExt mk(const Y& y) - { - return std::make_shared>(y.lowest()); - } - }; - - template - struct SptrExtT> - { - static DExt mk(const DExtTX& y) - { - return y.lowest(); - } - }; - /* - template - struct SptrExtT> - { - static DExt mk(const ExtT& y) - { - return std::make_shared>(y); - } - }; - */ template class DExtTX { private: mutable DExt mDExt = nullptr; X mNext; - - static DExt getDeepCopy(const DExtTX& in) { if(in.mDExt) return in.mDExt->deepCopy(); else return DExt(); } - public: static constexpr size_t NUM = X::SIZE; static constexpr size_t SIZE = NUM + 1; - //DExtTX() { VCHECK(mDExt->val()) ;mDExt = std::make_shared>(); } - DExtTX() = default; - DExtTX(const DExtTX& in) : mDExt(getDeepCopy(in)), mNext(in.mNext) {} - DExtTX(DExtTX&& in) : mDExt(getDeepCopy(in)), mNext(in.mNext) {} - DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = getDeepCopy(in); } - DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = getDeepCopy(in); } + DExtTX() { mDExt = std::make_shared>(); } + DExtTX(const DExtTX& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {} + DExtTX(DExtTX&& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {} + DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); } + DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); } DExtTX(const DExt& in) : mDExt(in) {} template - DExtTX& operator=(const Y& y) { mDExt = SptrExtT::mk(y); return *this; } + DExtTX& operator=(const Y& y) { mDExt = std::make_shared>(y); return *this; } template - DExtTX(const Y& y) : mDExt(SptrExtT::mk(y)) {} + DExtTX(const Y& y) : mDExt(std::make_shared>(y)) {} DExtTX(const DExt& y, const X& x) : mDExt(y), mNext(x) {} @@ -158,8 +117,7 @@ namespace MultiArrayHelper template inline const ExtType& expl() const - //{ if(mDExt == nullptr) mDExt = std::make_shared>(); assert(mDExt != nullptr); return mDExt->expl(); } - { return mDExt->expl(); } + { if(mDExt == nullptr) mDExt = std::make_shared>(); assert(mDExt != nullptr); return mDExt->expl(); } template inline auto extend(const Y& y) const -> DExtTX @@ -173,13 +131,6 @@ namespace MultiArrayHelper template inline auto nn() const -> decltype(Getter::getX(*this)) { return Getter::getX(*this); } - - inline std::string stype() const { return std::string("S[")+mDExt->stype()+"]"; } - - inline bool isInit() const { return mDExt != nullptr; } - - const DExt& lowest() const { return mDExt; } - DExt& lowest() { return mDExt; } }; typedef DExtTX DExtT; @@ -543,13 +494,7 @@ namespace MultiArrayHelper template const ExtType& ExtBase::expl() const { - VCHECK(this); - VCHECK(this->stype()); - auto xx = dynamic_cast*>(this); - VCHECK(xx); - ExtT xxx; - VCHECK(xxx.stype()); - return xx->ext(); + return dynamic_cast*>(this)->ext(); } /***************** @@ -577,9 +522,6 @@ namespace MultiArrayHelper template inline void For::operator()(size_t mlast, DExt last) { - VCHECK(last->stype()); - ExtType xxx; - VCHECK(xxx.stype()); operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); //operator()(mlast, *reinterpret_cast(last.first)); } @@ -627,7 +569,7 @@ namespace MultiArrayHelper template DExt For::dRootSteps(std::intptr_t iPtrNum) const { - return SptrExtT::mk(rootSteps(iPtrNum)); + return std::make_shared>(rootSteps(iPtrNum)); //mRootSteps = rootSteps(iPtrNum); //return std::make_pair(reinterpret_cast(&mRootSteps), // sizeof(ExtType)/sizeof(size_t)); @@ -636,7 +578,7 @@ namespace MultiArrayHelper template DExt For::dExtension() const { - return SptrExtT::mk(mExt); + return std::make_shared>(mExt); //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } @@ -739,7 +681,7 @@ namespace MultiArrayHelper template DExt PFor::dRootSteps(std::intptr_t iPtrNum) const { - return SptrExtT::mk(rootSteps(iPtrNum)); + return std::make_shared>(rootSteps(iPtrNum)); //mRootSteps = rootSteps(iPtrNum); //return std::make_pair(reinterpret_cast(&mRootSteps), // sizeof(ExtType)/sizeof(size_t)); @@ -748,7 +690,7 @@ namespace MultiArrayHelper template DExt PFor::dExtension() const { - return SptrExtT::mk(mExt); + return std::make_shared>(mExt); //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } @@ -826,7 +768,7 @@ namespace MultiArrayHelper template DExt SingleExpression::dRootSteps(std::intptr_t iPtrNum) const { - return SptrExtT::mk(rootSteps(iPtrNum)); + return std::make_shared>(rootSteps(iPtrNum)); //mRootSteps = rootSteps(iPtrNum); //return std::make_pair(reinterpret_cast(&mRootSteps), // sizeof(ExtType)/sizeof(size_t)); @@ -835,7 +777,7 @@ namespace MultiArrayHelper template DExt SingleExpression::dExtension() const { - return SptrExtT::mk(mExt); + return std::make_shared>(mExt); //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } @@ -913,7 +855,7 @@ namespace MultiArrayHelper template DExt SubExpr::dRootSteps(std::intptr_t iPtrNum) const { - return SptrExtT::mk(rootSteps(iPtrNum)); + return std::make_shared>(rootSteps(iPtrNum)); //mRootSteps = rootSteps(iPtrNum); //return std::make_pair(reinterpret_cast(&mRootSteps), //sizeof(ExtType)/sizeof(size_t)); @@ -922,7 +864,7 @@ namespace MultiArrayHelper template DExt SubExpr::dExtension() const { - return SptrExtT::mk(mExt); + return std::make_shared>(mExt); //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } @@ -968,7 +910,7 @@ namespace MultiArrayHelper inline void ExpressionHolder::operator()(size_t mlast, ExtType last) { mExpr(mlast, - SptrExtT::mk(last)); + std::make_shared>(last)); } template