add utilities in xfor.h + fix SIZE in SubExpr

This commit is contained in:
Christian Zimmermann 2019-07-10 18:14:50 +02:00
parent a2d67ef78c
commit b79f010c87
2 changed files with 30 additions and 7 deletions

View file

@ -13,6 +13,13 @@ namespace MultiArrayHelper
template <size_t N>
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>
static inline constexpr size_t lsize(const LTp& ltp)
{
@ -50,6 +57,13 @@ namespace MultiArrayHelper
template <>
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>
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
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;
typedef decltype(NN<LTpSize-1>::rootSteps(mLTp)) ExtType;
@ -123,6 +138,10 @@ namespace MultiArrayHelper
return NN<LTpSize-1>::rootSteps(mLTp,i);
}
VarTp& var() const
{
return mVarTp;
}
};
template <size_t N>
@ -237,6 +256,10 @@ namespace MultiArrayHelper
return mL.rootSteps(i);
}
auto var() const
{
return mL.var();
}
};
}

View file

@ -161,7 +161,7 @@ namespace MultiArrayHelper
typedef ExpressionBase EB;
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& operator=(const SubExpr& in) = default;