multi_array_operation: replace template spec by static if

This commit is contained in:
Christian Zimmermann 2021-06-25 17:28:22 +02:00
parent c282cf683d
commit ffb8e71dbd

View file

@ -592,24 +592,10 @@ namespace MultiArrayTools
return this->template asx<IPlus<T>>(in,i); return this->template asx<IPlus<T>>(in,i);
} }
template <bool VABLE = false> template <bool VABLE, template <typename> class F, typename TarOp, class OpClass>
struct VExec inline void vexec(TarOp& th, const OpClass& in)
{
template <template <typename> class F, typename TarOp, class OpClass>
static inline void exec(TarOp& th, const OpClass& in)
{
typedef typename TarOp::value_type T;
IAccess<T,F<T>> tmp;
th.template asx<decltype(tmp)>(in)();
}
};
template <>
struct VExec<true>
{
template <template <typename> class F, typename TarOp, class OpClass>
static inline void exec(TarOp& th, const OpClass& in)
{ {
if constexpr(VABLE){
CHECK; CHECK;
typedef typename TarOp::value_type T; typedef typename TarOp::value_type T;
auto x = th.template asx<IVAccess<T,F<T>>>(in); auto x = th.template asx<IVAccess<T,F<T>>>(in);
@ -622,13 +608,18 @@ namespace MultiArrayTools
th.template asx<IAccess<T,F<T>>>(in)(); th.template asx<IAccess<T,F<T>>>(in)();
} }
} }
}; else {
typedef typename TarOp::value_type T;
IAccess<T,F<T>> tmp;
th.template asx<decltype(tmp)>(in)();
}
}
template <typename T, class... Ranges> template <typename T, class... Ranges>
template <class OpClass> template <class OpClass>
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in) OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
{ {
VExec<OpClass::VABLE>::template exec<identity>(*this,in); vexec<OpClass::VABLE,identity>(*this,in);
return *this; return *this;
} }
@ -636,7 +627,7 @@ namespace MultiArrayTools
template <class OpClass> template <class OpClass>
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in) OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
{ {
VExec<OpClass::VABLE>::template exec<xxxplus>(*this,in); vexec<OpClass::VABLE,xxxplus>(*this,in);
return *this; return *this;
} }
@ -807,7 +798,7 @@ namespace MultiArrayTools
template <class OpClass> template <class OpClass>
ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::operator=(const OpClass& in) ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::operator=(const OpClass& in)
{ {
VExec<OpClass::VABLE>::template exec<identity>(*this,in); vexec<OpClass::VABLE,identity>(*this,in);
return *this; return *this;
} }
@ -815,7 +806,7 @@ namespace MultiArrayTools
template <class OpClass> template <class OpClass>
ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::operator+=(const OpClass& in) ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::operator+=(const OpClass& in)
{ {
VExec<OpClass::VABLE>::template exec<xxxplus>(*this,in); vexec<OpClass::VABLE,xxxplus>(*this,in);
return *this; return *this;
} }