diff --git a/src/include/xpr/vpos_type.cc.h b/src/include/xpr/vpos_type.cc.h index 69f6461..19ebb9a 100644 --- a/src/include/xpr/vpos_type.cc.h +++ b/src/include/xpr/vpos_type.cc.h @@ -7,28 +7,6 @@ namespace CNORXZ { - /**************** - * VPosBase * - ****************/ - /* - template - inline Uptr VPosBase::vextend(const SPos& a) const - { - return this->vextend(UPos(N)); - } - - template - inline Uptr VPosBase::vextend(const SFPos& a) const - { - return this->vextend(static_cast(a)); - } - - template - inline Uptr VPosBase::vextend(const MPos& a) const - { - return this->vextend(static_cast(a))->vextend(a.next()); - } - */ /************ * VPos * ************/ @@ -88,35 +66,7 @@ namespace CNORXZ typedef decltype((*this)(UPos(a->vval()))) OPosT; return std::make_unique>( (*this)(UPos(a->vval())) ); } - /* - template - Uptr VPos::vextend(const UPos& a) const - { - typedef decltype(this->extend(a)) OPosT; - return std::make_unique>(this->extend(a)); - } - template - Uptr VPos::vextend(const FPos& a) const - { - typedef decltype(this->extend(a)) OPosT; - return std::make_unique>(this->extend(a)); - } - - template - Uptr VPos::vextend(const DPos& a) const - { - typedef decltype(this->extend(a)) OPosT; - return std::make_unique>(this->extend(a)); - } - - template - Uptr VPos::vextend(const DPosRef& a) const - { - typedef decltype(this->extend(DPos(a))) OPosT; - return std::make_unique>(this->extend(DPos(a))); - } - */ /****************** * VPos * ******************/ @@ -190,8 +140,8 @@ namespace CNORXZ template Uptr VPos>::vplus(const VPosBase* a) const { - typedef decltype((*this) + DPosRef(a)) OPosT; - return std::make_unique>((*this) + DPosRef(a)); + typedef decltype((*this) + PosFromVPos>::make(a)) OPosT; + return std::make_unique>((*this) + PosFromVPos>::make(a)); } template @@ -207,35 +157,7 @@ namespace CNORXZ typedef decltype( (*this)(UPos(a->vval())) ) OPosT; return std::make_unique>( (*this)(UPos(a->vval())) ); } - /* - template - Uptr VPos>::vextend(const UPos& a) const - { - typedef decltype(this->extend(DPos(a))) OPosT; - return std::make_unique>(this->extend(DPos(a))); - } - - template - Uptr VPos>::vextend(const FPos& a) const - { - typedef decltype(this->extend(DPos(a))) OPosT; - return std::make_unique>(this->extend(DPos(a))); - } - template - Uptr VPos>::vextend(const DPos& a) const - { - typedef decltype(this->extend(a)) OPosT; - return std::make_unique>(this->extend(a)); - } - - template - Uptr VPos>::vextend(const DPosRef& a) const - { - typedef decltype(this->extend(DPos(a))) OPosT; - return std::make_unique>(this->extend(DPos(a))); - } - */ /*************** * VPosRef * ***************/ @@ -295,35 +217,7 @@ namespace CNORXZ typedef decltype( (*mC)(UPos(a->vval())) ) OPosT; return std::make_unique>( (*mC)(UPos(a->vval())) ); } - /* - template - Uptr VPosRef::vextend(const UPos& a) const - { - typedef decltype(mC->extend(a)) OPosT; - return std::make_unique>(mC->extend(a)); - } - - template - Uptr VPosRef::vextend(const FPos& a) const - { - typedef decltype(mC->extend(a)) OPosT; - return std::make_unique>(mC->extend(a)); - } - template - Uptr VPosRef::vextend(const DPos& a) const - { - typedef decltype(mC->extend(a)) OPosT; - return std::make_unique>(mC->extend(a)); - } - - template - Uptr VPosRef::vextend(const DPosRef& a) const - { - typedef decltype(mC->extend(DPos(a))) OPosT; - return std::make_unique>(mC->extend(DPos(a))); - } - */ /********************* * VPosRef * *********************/ @@ -376,8 +270,8 @@ namespace CNORXZ template Uptr VPosRef>::vplus(const VPosBase* a) const { - typedef decltype((*mC) + DPosRef(a)) OPosT; - return std::make_unique>((*mC) + DPosRef(a)); + typedef decltype((*mC) + PosFromVPos>::make(a)) OPosT; + return std::make_unique>((*mC) + PosFromVPos>::make(a)); } template @@ -393,35 +287,25 @@ namespace CNORXZ typedef decltype( (*mC)(UPos(a->vval())) ) OPosT; return std::make_unique>( (*mC)(UPos(a->vval())) ); } - /* - template - Uptr VPosRef>::vextend(const UPos& a) const - { - typedef decltype(mC->extend(DPos(a))) OPosT; - return std::make_unique>(mC->extend(DPos(a))); - } - - template - Uptr VPosRef>::vextend(const FPos& a) const - { - typedef decltype(mC->extend(DPos(a))) OPosT; - return std::make_unique>(mC->extend(DPos(a))); - } - - template - Uptr VPosRef>::vextend(const DPos& a) const - { - typedef decltype(mC->extend(a)) OPosT; - return std::make_unique>(mC->extend(a)); - } - template - Uptr VPosRef>::vextend(const DPosRef& a) const + /******************* + * PosFromVPos * + *******************/ + + template + inline decltype(auto) PosFromVPos::make(const VPosBase* a) { - typedef decltype(mC->extend(DPos(a))) OPosT; - return std::make_unique>(mC->extend(DPos(a))); + return PosT(a->vval()); + } + + template + inline decltype(auto) PosFromVPos>::make(const VPosBase* a) + { +#if CXZ_DEBUG + CXZ_ASSERT(a->vnext() != nullptr, "VPos does not match required size"); +#endif + return MPos(a->vval(), PosFromVPos::make(a->vnext())); } - */ } #endif diff --git a/src/include/xpr/vpos_type.h b/src/include/xpr/vpos_type.h index f2f85ec..fd86d2e 100644 --- a/src/include/xpr/vpos_type.h +++ b/src/include/xpr/vpos_type.h @@ -4,8 +4,6 @@ #include "base/base.h" -#define MAX_VMPOS_DEPTH 4 - namespace CNORXZ { class VPosBase @@ -21,20 +19,6 @@ namespace CNORXZ virtual Uptr vplus(const VPosBase* a) const = 0; virtual Uptr vtimes(const VPosBase* a) const = 0; virtual Uptr vexec(const VPosBase* a) const = 0; - //virtual Uptr vextend(const UPos& a) const = 0; - //virtual Uptr vextend(const FPos& a) const = 0; - //virtual Uptr vextend(const DPos& a) const = 0; - //virtual Uptr vextend(const DPosRef& a) const = 0; - /* - template - inline Uptr vextend(const SPos& a) const; - - template - inline Uptr vextend(const SFPos& a) const; - - template - inline Uptr vextend(const MPos& a) const; - */ }; template @@ -53,10 +37,6 @@ namespace CNORXZ virtual Uptr vplus(const VPosBase* a) const override final; virtual Uptr vtimes(const VPosBase* a) const override final; virtual Uptr vexec(const VPosBase* a) const override final; - //virtual Uptr vextend(const UPos& a) const override final; - //virtual Uptr vextend(const FPos& a) const override final; - //virtual Uptr vextend(const DPos& a) const override final; - //virtual Uptr vextend(const DPosRef& a) const override final; }; template @@ -81,10 +61,6 @@ namespace CNORXZ virtual Uptr vplus(const VPosBase* a) const override final; virtual Uptr vtimes(const VPosBase* a) const override final; virtual Uptr vexec(const VPosBase* a) const override final; - //virtual Uptr vextend(const UPos& a) const override final; - //virtual Uptr vextend(const FPos& a) const override final; - //virtual Uptr vextend(const DPos& a) const override final; - //virtual Uptr vextend(const DPosRef& a) const override final; }; template @@ -105,10 +81,6 @@ namespace CNORXZ virtual Uptr vplus(const VPosBase* a) const override final; virtual Uptr vtimes(const VPosBase* a) const override final; virtual Uptr vexec(const VPosBase* a) const override final; - //virtual Uptr vextend(const UPos& a) const override final; - //virtual Uptr vextend(const FPos& a) const override final; - //virtual Uptr vextend(const DPos& a) const override final; - //virtual Uptr vextend(const DPosRef& a) const override final; }; @@ -133,10 +105,6 @@ namespace CNORXZ virtual Uptr vplus(const VPosBase* a) const override final; virtual Uptr vtimes(const VPosBase* a) const override final; virtual Uptr vexec(const VPosBase* a) const override final; - //virtual Uptr vextend(const UPos& a) const override final; - //virtual Uptr vextend(const FPos& a) const override final; - //virtual Uptr vextend(const DPos& a) const override final; - //virtual Uptr vextend(const DPosRef& a) const override final; }; @@ -180,6 +148,17 @@ namespace CNORXZ class VPosRef {}; + template + struct PosFromVPos + { + static inline decltype(auto) make(const VPosBase* a); + }; + + template + struct PosFromVPos> + { + static inline decltype(auto) make(const VPosBase* a); + }; } diff --git a/src/tests/xpr_unit_test.cc b/src/tests/xpr_unit_test.cc index 30f67b2..bb2280d 100644 --- a/src/tests/xpr_unit_test.cc +++ b/src/tests/xpr_unit_test.cc @@ -157,38 +157,6 @@ namespace EXPECT_EQ(dp5.sub().val(), mS4p.val() * mUp1.val()); } - TEST_F(Pos_Test, DynExtend) - {/* - DPos dp1(mkMPos(static_cast(mS2p), mUp1)); - DPos dp2(mkMPos(mUp2, static_cast(mS4p))); - auto dp3 = dp1.extend(mUp2); - auto dp4 = dp2.extend(mS2p); - auto dp5 = dp3 + dp4; - DPos dp01(mUp1); - auto dp6 = dp3 * dp01; - - EXPECT_EQ( dp3.size(), 3u ); - EXPECT_EQ( dp4.size(), 3u ); - - EXPECT_EQ( dp3.val(), mS2p.val() ); - EXPECT_EQ( dp3.next().val(), mUp1.val() ); - EXPECT_EQ( dp3.next().next().val(), mUp2.val() ); - - EXPECT_EQ( dp4.val(), mUp2.val() ); - EXPECT_EQ( dp4.next().val(), mS4p.val() ); - EXPECT_EQ( dp4.next().next().val(), mS2p.val() ); - - EXPECT_EQ( dp5.size(), 3u ); - EXPECT_EQ( dp6.size(), 3u ); - - EXPECT_EQ( dp5.val(), dp3.val() + dp4.val() ); - EXPECT_EQ( dp5.next().val(), dp3.next().val() + dp4.next().val() ); - EXPECT_EQ( dp5.next().next().val(), dp3.next().next().val() + dp4.next().next().val() ); - - EXPECT_EQ( dp6.val(), dp3.val() * dp01.val() ); - EXPECT_EQ( dp6.next().val(), dp3.next().val() * dp01.val() ); - EXPECT_EQ( dp6.next().next().val(), dp3.next().next().val() * dp01.val() ); - */} } int main(int argc, char** argv)