various fixes (relevant for higher level meta programing)
This commit is contained in:
parent
f47ca055db
commit
861adac36a
6 changed files with 57 additions and 14 deletions
|
@ -68,7 +68,7 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using vector = std::vector<T,MultiArrayHelper::Allocator<T>>;
|
using vector = std::vector<T,MultiArrayHelper::Allocator<T>>;
|
||||||
|
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,10 +38,11 @@ namespace MultiArrayTools
|
||||||
class OpExpr
|
class OpExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef decltype(mkMapOp(std::declval<MapF>(), std::declval<IndexPack>())) Op;
|
||||||
typedef SingleIndex<typename MapF::value_type,STYPE> OIType;
|
typedef SingleIndex<typename MapF::value_type,STYPE> OIType;
|
||||||
//typedef typename MapF::IndexPack IndexPack;
|
//typedef typename MapF::IndexPack IndexPack;
|
||||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||||
static constexpr size_t SIZE = Expr::SIZE;
|
static constexpr size_t SIZE = Expr::SIZE + Op::SIZE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpExpr() = default;
|
OpExpr() = default;
|
||||||
|
@ -51,8 +52,6 @@ namespace MultiArrayTools
|
||||||
size_t mMax;
|
size_t mMax;
|
||||||
size_t mStep;
|
size_t mStep;
|
||||||
Expr mExpr;
|
Expr mExpr;
|
||||||
|
|
||||||
typedef decltype(mkMapOp(std::declval<MapF>(), std::declval<IndexPack>())) Op;
|
|
||||||
Op mOp;
|
Op mOp;
|
||||||
|
|
||||||
typedef decltype(mOp.rootSteps(std::declval<intptr_t>()).extend( mExpr.rootSteps(std::declval<intptr_t>()) )) ExtType;
|
typedef decltype(mOp.rootSteps(std::declval<intptr_t>()).extend( mExpr.rootSteps(std::declval<intptr_t>()) )) ExtType;
|
||||||
|
|
|
@ -346,6 +346,7 @@ namespace MultiArrayTools
|
||||||
auto OperationRoot<T,Ranges...>::assign(const OpClass& in)
|
auto OperationRoot<T,Ranges...>::assign(const OpClass& in)
|
||||||
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr<T,OpClass>(mOrigDataPtr,in))))
|
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr<T,OpClass>(mOrigDataPtr,in))))
|
||||||
{
|
{
|
||||||
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return mIndex.ifor(1,in.loop(AssignmentExpr<T,OpClass>(mOrigDataPtr,in)));
|
return mIndex.ifor(1,in.loop(AssignmentExpr<T,OpClass>(mOrigDataPtr,in)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +355,7 @@ namespace MultiArrayTools
|
||||||
auto OperationRoot<T,Ranges...>::plus(const OpClass& in)
|
auto OperationRoot<T,Ranges...>::plus(const OpClass& in)
|
||||||
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))))
|
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))))
|
||||||
{
|
{
|
||||||
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in)));
|
return mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,9 +558,9 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MExt<void> OperationValue<T>::rootSteps(std::intptr_t iPtrNum) const
|
None OperationValue<T>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return MExt<void>(0);
|
return None();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -388,7 +388,7 @@ namespace MultiArrayTools
|
||||||
typedef ContainerRange<T,NullRange> CRange;
|
typedef ContainerRange<T,NullRange> CRange;
|
||||||
typedef ContainerIndex<T,NullIndex> IndexType;
|
typedef ContainerIndex<T,NullIndex> IndexType;
|
||||||
|
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 0;
|
||||||
static constexpr bool CONT = true;
|
static constexpr bool CONT = true;
|
||||||
|
|
||||||
OperationValue(const T& val);
|
OperationValue(const T& val);
|
||||||
|
@ -399,7 +399,7 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline OperationValue& set(ET pos);
|
inline OperationValue& set(ET pos);
|
||||||
|
|
||||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
None rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
Expr loop(Expr exp) const;
|
Expr loop(Expr exp) const;
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace MultiArrayHelper
|
||||||
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
||||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
static_assert(LAST >= NextOpType::SIZE, "inconsistent array positions");
|
||||||
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
||||||
typedef decltype(std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos ))) ArgT;
|
typedef decltype(std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos ))) ArgT;
|
||||||
return PackNum<N-1>::template mkOpExpr<NEXT,T,ETuple,OpTuple,OpFunction,ArgT,Args...>
|
return PackNum<N-1>::template mkOpExpr<NEXT,T,ETuple,OpTuple,OpFunction,ArgT,Args...>
|
||||||
|
|
|
@ -52,7 +52,8 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static constexpr size_t NUM = X::NUM + 1;
|
static constexpr size_t NUM = X::SIZE;
|
||||||
|
static constexpr size_t SIZE = NUM + 1;
|
||||||
|
|
||||||
MExt() = default;
|
MExt() = default;
|
||||||
MExt(const MExt& in) = default;
|
MExt(const MExt& in) = default;
|
||||||
|
@ -71,6 +72,9 @@ namespace MultiArrayHelper
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline MExt(const std::array<size_t,N>& arr);
|
inline MExt(const std::array<size_t,N>& arr);
|
||||||
|
|
||||||
|
template <class Y>
|
||||||
|
inline MExt(const MExt<Y>& y);
|
||||||
|
|
||||||
inline const size_t& val() const;
|
inline const size_t& val() const;
|
||||||
inline const X& next() const;
|
inline const X& next() const;
|
||||||
|
|
||||||
|
@ -88,6 +92,27 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct None
|
||||||
|
{
|
||||||
|
None() = default;
|
||||||
|
None(const None& in) = default;
|
||||||
|
None(None&& in) = default;
|
||||||
|
None& operator=(const None& in) = default;
|
||||||
|
None& operator=(None&& in) = default;
|
||||||
|
|
||||||
|
template <class Y>
|
||||||
|
None(const Y& y) {}
|
||||||
|
|
||||||
|
static constexpr size_t SIZE = 0;
|
||||||
|
|
||||||
|
inline None operator+(const None& in) const { return None(); }
|
||||||
|
inline None operator*(size_t in) const { return None(); }
|
||||||
|
|
||||||
|
template <class Y>
|
||||||
|
Y extend(const Y& y) const
|
||||||
|
{ return y; }
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class MExt<void>
|
class MExt<void>
|
||||||
{
|
{
|
||||||
|
@ -98,7 +123,8 @@ namespace MultiArrayHelper
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static constexpr size_t NUM = 0;
|
static constexpr size_t NUM = 0;
|
||||||
|
static constexpr size_t SIZE = NUM + 1;
|
||||||
|
|
||||||
MExt() = default;
|
MExt() = default;
|
||||||
MExt(const MExt& in) = default;
|
MExt(const MExt& in) = default;
|
||||||
MExt& operator=(const MExt& in) = default;
|
MExt& operator=(const MExt& in) = default;
|
||||||
|
@ -107,17 +133,24 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
inline MExt(size_t ext);
|
inline MExt(size_t ext);
|
||||||
|
|
||||||
|
inline MExt(size_t y, const None& z) : mExt(y) {}
|
||||||
|
|
||||||
template <class Z>
|
template <class Z>
|
||||||
inline MExt(size_t y, const Z& z);
|
inline MExt(size_t y, const Z& z);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class Y, class Z>
|
template <class Y, class Z>
|
||||||
inline MExt(const Y& y, const Z& z);
|
inline MExt(const Y& y, const Z& z);
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline MExt(const std::array<size_t,N>& arr);
|
inline MExt(const std::array<size_t,N>& arr);
|
||||||
|
|
||||||
|
template <class Y>
|
||||||
|
inline MExt(const MExt<Y>& y);
|
||||||
|
|
||||||
inline const size_t& val() const;
|
inline const size_t& val() const;
|
||||||
inline size_t next() const { return 0; }
|
inline None next() const { return None(); }
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline auto nn() const
|
inline auto nn() const
|
||||||
|
@ -161,7 +194,12 @@ namespace MultiArrayHelper
|
||||||
template <class Y, class Z>
|
template <class Y, class Z>
|
||||||
inline MExt<X>::MExt(const Y& y, const Z& z) :
|
inline MExt<X>::MExt(const Y& y, const Z& z) :
|
||||||
mExt(y.val()), mNext(y.next(), z) {}
|
mExt(y.val()), mNext(y.next(), z) {}
|
||||||
|
|
||||||
|
template <class X>
|
||||||
|
template <class Y>
|
||||||
|
inline MExt<X>::MExt(const MExt<Y>& y) :
|
||||||
|
mExt(y.val()), mNext(y.next()) {}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline const size_t& MExt<X>::val() const
|
inline const size_t& MExt<X>::val() const
|
||||||
{
|
{
|
||||||
|
@ -207,6 +245,10 @@ namespace MultiArrayHelper
|
||||||
inline MExt<void>::MExt(const std::array<size_t,N>& arr) :
|
inline MExt<void>::MExt(const std::array<size_t,N>& arr) :
|
||||||
mExt(std::get<NUM>(arr)) {}
|
mExt(std::get<NUM>(arr)) {}
|
||||||
|
|
||||||
|
template <class Y>
|
||||||
|
inline MExt<void>::MExt(const MExt<Y>& y) :
|
||||||
|
mExt(y.val()) {}
|
||||||
|
|
||||||
//template <>
|
//template <>
|
||||||
inline const size_t& MExt<void>::val() const
|
inline const size_t& MExt<void>::val() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue