diff --git a/src/include/ranges/ranges.cc.h b/src/include/ranges/ranges.cc.h index 19be012..4519d63 100644 --- a/src/include/ranges/ranges.cc.h +++ b/src/include/ranges/ranges.cc.h @@ -17,6 +17,7 @@ #include "wrange.cc.h" #include "srange.cc.h" #include "crange.cc.h" +#include "yrange.cc.h" #include "prange.cc.h" #include "dindex.cc.h" #include "lindex.cc.h" diff --git a/src/include/ranges/yrange.cc.h b/src/include/ranges/yrange.cc.h new file mode 100644 index 0000000..2666ead --- /dev/null +++ b/src/include/ranges/yrange.cc.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +/** + + @file include/ranges/yrange.cc.h + @brief YRange and YIndex template implementations. + + Copyright (c) 2024 Christian Zimmermann. All rights reserved. + Mail: chizeta@f3l.de + +**/ + +#ifndef __cxz_yrange_cc_h__ +#define __cxz_yrange_cc_h__ + +#include "yrange.h" +#include "index_mul.h" + +namespace CNORXZ +{ + template + DXpr YIndex::ifor(const Xpr& xpr, NoF&& f) const + { + return this->ifor( DXpr(xpr), std::forward(f) ); + } + + template + decltype(auto) operator*(const Sptr& a, const Sptr& b) + { + return iptrMul(a, b); + } + +} + +#endif diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index 53a62f6..96800b7 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -154,6 +154,10 @@ namespace CNORXZ /** @copydoc IndexInterface::ifor() */ DXpr ifor(const DXpr& xpr, NoF&& f) const; + /** @copydoc IndexInterface::ifor() */ + template + DXpr ifor(const Xpr& xpr, NoF&& f) const; + /** @copydoc IndexInterface::formatIsTrivial() */ bool formatIsTrivial() const; @@ -361,6 +365,12 @@ namespace CNORXZ static Sptr func(const RangePtr& r); }; + /** Make index pack of a YIndex and another index. + @param a pointer to YIndex. + @param b pointer to another index. + */ + template + decltype(auto) operator*(const Sptr& a, const Sptr& b); } diff --git a/src/include/xpr/xpr_base.cc.h b/src/include/xpr/xpr_base.cc.h index f51afa2..69b46c6 100644 --- a/src/include/xpr/xpr_base.cc.h +++ b/src/include/xpr/xpr_base.cc.h @@ -16,6 +16,35 @@ namespace CNORXZ { + // TODO: move to a better place!!! + template + struct PosFromDPos + { + static constexpr decltype(auto) mk(const DPos& pos) + { + if constexpr(std::is_same::value or std::is_same::value){ + return pos; + } + else { + return UPos(pos.val()); + } + } + }; + + template + struct PosFromDPos> + { + static constexpr decltype(auto) mk(const DPos& pos) + { + return mkMPos( PosFromDPos::mk(pos), PosFromDPos::mk( pos.sub() ) ); + } + }; + + template + constexpr decltype(auto) mkMPosFromDPos(const DPos& pos) + { + return PosFromDPos::mk(pos); + } /*==========+ | VXpr | @@ -35,13 +64,28 @@ namespace CNORXZ template T VXpr::vexec(const DPos& last) const { - return (*this)(last); + typedef typename std::remove_referencerootSteps(IndexId<0>{}))>::type Ext; + typedef decltype((*this)()) RetT; + if constexpr(std::is_same::value){ + (*this)(mkMPosFromDPos(last)); + return None {}; + } + else { + return (*this)(mkMPosFromDPos(last)); + } } template T VXpr::vexec() const { - return (*this)(); + typedef decltype((*this)()) RetT; + if constexpr(std::is_same::value){ + (*this)(); + return None {}; + } + else { + return (*this)(); + } } template