add utilities in xfor.h + fix SIZE in SubExpr
This commit is contained in:
parent
a2d67ef78c
commit
b79f010c87
2 changed files with 30 additions and 7 deletions
|
@ -13,6 +13,13 @@ namespace MultiArrayHelper
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
struct NN
|
struct NN
|
||||||
{
|
{
|
||||||
|
template <class LTp>
|
||||||
|
static inline constexpr size_t LSIZE()
|
||||||
|
{
|
||||||
|
typedef typename std::tuple_element<N,LTp>::type LType;
|
||||||
|
return LType::SIZE + NN<N-1>::template LSIZE<LTp>();
|
||||||
|
}
|
||||||
|
|
||||||
template <class LTp>
|
template <class LTp>
|
||||||
static inline constexpr size_t lsize(const LTp& ltp)
|
static inline constexpr size_t lsize(const LTp& ltp)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +57,13 @@ namespace MultiArrayHelper
|
||||||
template <>
|
template <>
|
||||||
struct NN<0>
|
struct NN<0>
|
||||||
{
|
{
|
||||||
|
template <class LTp>
|
||||||
|
static inline constexpr size_t LSIZE()
|
||||||
|
{
|
||||||
|
typedef typename std::tuple_element<0,LTp>::type LType;
|
||||||
|
return LType::SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
template <class LTp>
|
template <class LTp>
|
||||||
static inline constexpr size_t lsize(const LTp& ltp)
|
static inline constexpr size_t lsize(const LTp& ltp)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +113,8 @@ namespace MultiArrayHelper
|
||||||
std::array<size_t,VarTpSize> mSetzero; // set variable to zero after each cycle
|
std::array<size_t,VarTpSize> mSetzero; // set variable to zero after each cycle
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr size_t SIZE = NN<LTpSize-1>::lsize(std::declval<LTp>());
|
//static constexpr size_t SIZE = NN<LTpSize-1>::lsize(std::declval<LTp>());
|
||||||
|
static constexpr size_t SIZE = NN<LTpSize-1>::template LSIZE<LTp>();
|
||||||
static constexpr bool CONT = false;
|
static constexpr bool CONT = false;
|
||||||
typedef decltype(NN<LTpSize-1>::rootSteps(mLTp)) ExtType;
|
typedef decltype(NN<LTpSize-1>::rootSteps(mLTp)) ExtType;
|
||||||
|
|
||||||
|
@ -123,6 +138,10 @@ namespace MultiArrayHelper
|
||||||
return NN<LTpSize-1>::rootSteps(mLTp,i);
|
return NN<LTpSize-1>::rootSteps(mLTp,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VarTp& var() const
|
||||||
|
{
|
||||||
|
return mVarTp;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
|
@ -237,6 +256,10 @@ namespace MultiArrayHelper
|
||||||
return mL.rootSteps(i);
|
return mL.rootSteps(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto var() const
|
||||||
|
{
|
||||||
|
return mL.var();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace MultiArrayHelper
|
||||||
typedef ExpressionBase EB;
|
typedef ExpressionBase EB;
|
||||||
|
|
||||||
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 + 1;
|
||||||
|
|
||||||
SubExpr(const SubExpr& in) = default;
|
SubExpr(const SubExpr& in) = default;
|
||||||
SubExpr& operator=(const SubExpr& in) = default;
|
SubExpr& operator=(const SubExpr& in) = default;
|
||||||
|
|
Loading…
Reference in a new issue