This commit is contained in:
Christian Zimmermann 2022-10-13 00:30:37 +02:00
parent c7e66f081c
commit d804f5db7e
3 changed files with 37 additions and 22 deletions

View file

@ -238,8 +238,6 @@ namespace CNORXZ
{ {
static_assert(is_scalar_pos_type<BPosT>::value, static_assert(is_scalar_pos_type<BPosT>::value,
"MPos has to be derived from scalar pos type"); "MPos has to be derived from scalar pos type");
static_assert(pos_depth<NPosT>::value < MAX_VMPOS_DEPTH,
"preliminary...");
} }
template <class BPosT, class NPosT> template <class BPosT, class NPosT>
@ -248,8 +246,6 @@ namespace CNORXZ
{ {
static_assert(is_scalar_pos_type<BPosT>::value, static_assert(is_scalar_pos_type<BPosT>::value,
"MPos has to be derived from scalar pos type"); "MPos has to be derived from scalar pos type");
static_assert(pos_depth<NPosT>::value < MAX_VMPOS_DEPTH,
"preliminary...");
} }
template <class BPosT, class NPosT> template <class BPosT, class NPosT>
@ -259,8 +255,6 @@ namespace CNORXZ
{ {
static_assert(is_scalar_pos_type<BPosT>::value, static_assert(is_scalar_pos_type<BPosT>::value,
"MPos has to be derived from scalar pos type"); "MPos has to be derived from scalar pos type");
static_assert(pos_depth<NPosT>::value < MAX_VMPOS_DEPTH,
"preliminary...");
} }
template <class BPosT, class NPosT> template <class BPosT, class NPosT>
@ -270,8 +264,6 @@ namespace CNORXZ
{ {
static_assert(is_scalar_pos_type<BPosT>::value, static_assert(is_scalar_pos_type<BPosT>::value,
"MPos has to be derived from scalar pos type"); "MPos has to be derived from scalar pos type");
static_assert(pos_depth<NPosT>::value < MAX_VMPOS_DEPTH,
"preliminary...");
} }
template <class BPosT, class NPosT> template <class BPosT, class NPosT>
@ -384,7 +376,8 @@ namespace CNORXZ
return DPos(mC->vplus( a.vpos() )); return DPos(mC->vplus( a.vpos() ));
} }
else { else {
return DPos(mC->vplus( VPosRef<PosT>(&a) )); VPosRef<PosT> b(&a);
return DPos(mC->vplus( &b ));
} }
} }
@ -395,7 +388,8 @@ namespace CNORXZ
return DPos(mC->vtimes( a.vpos() )); return DPos(mC->vtimes( a.vpos() ));
} }
else { else {
return DPos(mC->vtimes( VPosRef<PosT>(&a) )); VPosRef<PosT> b(&a);
return DPos(mC->vtimes( &b ));
} }
} }
@ -407,7 +401,8 @@ namespace CNORXZ
return DPos(mC->vexec( a.vpos() )); return DPos(mC->vexec( a.vpos() ));
} }
else { else {
return DPos(mC->vexec( VPosRef<PosT>(&a) )); VPosRef<PosT> b(&a);
return DPos(mC->vexec( &b ));
} }
} }

View file

@ -156,9 +156,12 @@ namespace CNORXZ
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
VPos<MPos<PosT1,PosT2>>::VPos(const MPos<PosT1,PosT2>& a) : VPos<MPos<PosT1,PosT2>>::VPos(const MPos<PosT1,PosT2>& a) :
MPos<PosT1,PosT2>(a), MPos<PosT1,PosT2>(a),
mTRef(static_cast<const PosT1*>(this)), mTRef(static_cast<const PosT1*>(this))
mNRef(&this->next()) {
{} if constexpr(not std::is_same<PosT2,DPos>::value){
mNRef = VPosRef<PosT2>(&this->next());
}
}
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
Uptr<VPosBase> VPos<MPos<PosT1,PosT2>>::copy() const Uptr<VPosBase> VPos<MPos<PosT1,PosT2>>::copy() const
@ -198,8 +201,13 @@ namespace CNORXZ
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
const VPosBase* VPos<MPos<PosT1,PosT2>>::vnext() const const VPosBase* VPos<MPos<PosT1,PosT2>>::vnext() const
{ {
if constexpr(not std::is_same<PosT2,DPos>::value){
return &mNRef; return &mNRef;
} }
else {
return this->next().get();
}
}
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
Uptr<VPosBase> VPos<MPos<PosT1,PosT2>>::vplus(const VPosBase* a) const Uptr<VPosBase> VPos<MPos<PosT1,PosT2>>::vplus(const VPosBase* a) const
@ -230,8 +238,10 @@ namespace CNORXZ
return std::make_unique<VPos<OPosT>>(this->extend(a)); return std::make_unique<VPos<OPosT>>(this->extend(a));
} }
else { else {
CXZ_ERROR("preliminary..."); typedef decltype(this->extend(DPos(a))) OPosT;
return nullptr; return std::make_unique<VPos<OPosT>>(this->extend(DPos(a)));
//CXZ_ERROR("preliminary...");
//return nullptr;
} }
} }
@ -340,9 +350,12 @@ namespace CNORXZ
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
VPosRef<MPos<PosT1,PosT2>>::VPosRef(const MPos<PosT1,PosT2>* c) : VPosRef<MPos<PosT1,PosT2>>::VPosRef(const MPos<PosT1,PosT2>* c) :
mC(c), mC(c),
mTRef(static_cast<const PosT1*>(mC)), mTRef(static_cast<const PosT1*>(mC))
mNRef(&c->next()) {
{} if constexpr(not std::is_same<PosT2,DPos>::value){
mNRef = VPosRef<PosT2>(&c->next());
}
}
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
Uptr<VPosBase> VPosRef<MPos<PosT1,PosT2>>::copy() const Uptr<VPosBase> VPosRef<MPos<PosT1,PosT2>>::copy() const
@ -382,8 +395,13 @@ namespace CNORXZ
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
const VPosBase* VPosRef<MPos<PosT1,PosT2>>::vnext() const const VPosBase* VPosRef<MPos<PosT1,PosT2>>::vnext() const
{ {
if constexpr(not std::is_same<PosT2,DPos>::value){
return &mNRef; return &mNRef;
} }
else {
return mC->next().get();
}
}
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
Uptr<VPosBase> VPosRef<MPos<PosT1,PosT2>>::vplus(const VPosBase* a) const Uptr<VPosBase> VPosRef<MPos<PosT1,PosT2>>::vplus(const VPosBase* a) const
@ -431,6 +449,7 @@ namespace CNORXZ
return nullptr; return nullptr;
} }
} }
} }
#endif #endif

View file

@ -4,7 +4,7 @@
#include "base/base.h" #include "base/base.h"
#define MAX_VMPOS_DEPTH 10 #define MAX_VMPOS_DEPTH 4
namespace CNORXZ namespace CNORXZ
{ {
@ -107,6 +107,7 @@ namespace CNORXZ
}; };
template <class PosT1, class PosT2> template <class PosT1, class PosT2>
class VPosRef<MPos<PosT1,PosT2>> : public VPosBase class VPosRef<MPos<PosT1,PosT2>> : public VPosBase
{ {