fix epos operations (oget)

This commit is contained in:
Christian Zimmermann 2024-07-28 08:45:34 +02:00
parent b2dcf54d65
commit 2ca37810b2
2 changed files with 14 additions and 4 deletions

View file

@ -711,13 +711,13 @@ namespace CNORXZ
static_assert(((static_pos_size<OPosTs>::value == 1) and ...), "only single pos types allowed"); static_assert(((static_pos_size<OPosTs>::value == 1) and ...), "only single pos types allowed");
if constexpr(is_epos_type<PosT>::value){ if constexpr(is_epos_type<PosT>::value){
return iter<0,sizeof...(OPosTs)> return iter<0,sizeof...(OPosTs)>
( [&](auto i) { return std::get<i>(mP)+a.template get<i>(); }, ( [&](auto i) { return std::get<i>(mP)+a.template oget<i>(); },
[&](const auto&... e) { return epos(BPosT::operator+(a.scal()),e...); } ); [&](const auto&... e) { return epos(BPosT::operator+(a.scal()),e...); } );
} }
else { else {
auto ax = mkEPos<sizeof...(OPosTs)>(a,a*SPos<0>{}); auto ax = mkEPos<sizeof...(OPosTs)>(a,a*SPos<0>{});
return iter<0,sizeof...(OPosTs)> return iter<0,sizeof...(OPosTs)>
( [&](auto i) { return std::get<i>(mP)+ax.template get<i>(); }, ( [&](auto i) { return std::get<i>(mP)+ax.template oget<i>(); },
[&](const auto&... e) { return epos(BPosT::operator+(a),e...); } ); [&](const auto&... e) { return epos(BPosT::operator+(a),e...); } );
} }
} }
@ -731,7 +731,7 @@ namespace CNORXZ
if constexpr(is_epos_type<PosT>::value){ if constexpr(is_epos_type<PosT>::value){
return iter<0,sizeof...(OPosTs)> return iter<0,sizeof...(OPosTs)>
( [&](auto i) { auto x = scal(); auto y = a.scal(); ( [&](auto i) { auto x = scal(); auto y = a.scal();
auto q = std::get<i>(mP); auto p = a.template get<i>(); auto q = std::get<i>(mP); auto p = a.template oget<i>();
return x*p+q*(y+p); }, return x*p+q*(y+p); },
[&](const auto&... e) { return epos(BPosT::operator*(a.scal()),e...); } ); [&](const auto&... e) { return epos(BPosT::operator*(a.scal()),e...); } );
} }
@ -739,7 +739,7 @@ namespace CNORXZ
auto ax = mkEPos<sizeof...(OPosTs)>(a,a*SPos<0>{}); auto ax = mkEPos<sizeof...(OPosTs)>(a,a*SPos<0>{});
return iter<0,sizeof...(OPosTs)> return iter<0,sizeof...(OPosTs)>
( [&](auto i) { auto x = scal(); auto y = ax.scal(); ( [&](auto i) { auto x = scal(); auto y = ax.scal();
auto q = std::get<i>(mP); auto p = ax.template get<i>(); auto q = std::get<i>(mP); auto p = ax.template oget<i>();
return x*p+q*(y+p); }, return x*p+q*(y+p); },
[&](const auto&... e) { return epos(BPosT::operator*(a),e...); } ); [&](const auto&... e) { return epos(BPosT::operator*(a),e...); } );
} }
@ -783,6 +783,13 @@ namespace CNORXZ
return scal()+std::get<I>(mP); return scal()+std::get<I>(mP);
} }
template <class BPosT, class... OPosTs>
template <SizeT I>
constexpr decltype(auto) EPos<BPosT,OPosTs...>::oget() const
{
return std::get<I>(mP);
}
template <class BPosT, class... OPosTs> template <class BPosT, class... OPosTs>
template <SizeT... Is> template <SizeT... Is>
constexpr decltype(auto) EPos<BPosT,OPosTs...>::ival(std::index_sequence<Is...> is) const constexpr decltype(auto) EPos<BPosT,OPosTs...>::ival(std::index_sequence<Is...> is) const

View file

@ -311,6 +311,9 @@ namespace CNORXZ
template <SizeT I> template <SizeT I>
constexpr decltype(auto) get() const; constexpr decltype(auto) get() const;
template <SizeT I>
constexpr decltype(auto) oget() const; // offset only
}; };
template <class BPosT, class... OPosTs> template <class BPosT, class... OPosTs>