remove Application classes
This commit is contained in:
parent
fe22b1ad80
commit
9d85f8df46
2 changed files with 24 additions and 49 deletions
|
@ -9,26 +9,6 @@ namespace MultiArrayTools
|
||||||
* FunctionalMultiArray *
|
* FunctionalMultiArray *
|
||||||
****************************/
|
****************************/
|
||||||
|
|
||||||
template <bool FISSTATIC>
|
|
||||||
struct Application
|
|
||||||
{
|
|
||||||
template <typename T, class Function, typename Meta>
|
|
||||||
static inline T apply(const std::shared_ptr<Function>& f, const Meta& m)
|
|
||||||
{
|
|
||||||
return (*f)(m);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Application<true>
|
|
||||||
{
|
|
||||||
template <typename T, class Function, typename Meta>
|
|
||||||
static inline T apply(const std::shared_ptr<Function>& f, const Meta& m)
|
|
||||||
{
|
|
||||||
return Function::apply(m);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, class Function, class... SRanges>
|
template <typename T, class Function, class... SRanges>
|
||||||
FunctionalMultiArray<T,Function,SRanges...>::FunctionalMultiArray(const std::shared_ptr<SRanges>&... ranges,
|
FunctionalMultiArray<T,Function,SRanges...>::FunctionalMultiArray(const std::shared_ptr<SRanges>&... ranges,
|
||||||
const std::shared_ptr<Function>& func) :
|
const std::shared_ptr<Function>& func) :
|
||||||
|
@ -51,14 +31,24 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Function, class... SRanges>
|
template <typename T, class Function, class... SRanges>
|
||||||
const T& FunctionalMultiArray<T,Function,SRanges...>::operator[](const IndexType& i) const
|
const T& FunctionalMultiArray<T,Function,SRanges...>::operator[](const IndexType& i) const
|
||||||
{
|
{
|
||||||
mVal = Application<Function::FISSTATIC>::template apply<T,Function,typename IndexType::MetaType>(mFunc, i.meta());
|
if constexpr(Function::FISSTATIC){
|
||||||
|
mVal = Function::apply(i.meta());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mVal = (*mFunc)(i.meta());
|
||||||
|
}
|
||||||
return mVal;
|
return mVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class Function, class... SRanges>
|
template <typename T, class Function, class... SRanges>
|
||||||
const T& FunctionalMultiArray<T,Function,SRanges...>::at(const typename CRange::IndexType::MetaType& meta) const
|
const T& FunctionalMultiArray<T,Function,SRanges...>::at(const typename CRange::IndexType::MetaType& meta) const
|
||||||
{
|
{
|
||||||
mVal = Application<Function::FISSTATIC>::template apply<T,Function,typename IndexType::MetaType>(mFunc,meta);
|
if constexpr(Function::FISSTATIC){
|
||||||
|
mVal = Function::apply(meta);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mVal = (*mFunc)(meta);
|
||||||
|
}
|
||||||
return mVal;
|
return mVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,29 +13,6 @@
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
template <bool ISSTATIC>
|
|
||||||
struct Application
|
|
||||||
{
|
|
||||||
template <class OpFunction, typename... Ts>
|
|
||||||
static inline auto apply(std::shared_ptr<OpFunction> f, Ts... as)
|
|
||||||
-> decltype((*f)(as...))
|
|
||||||
{
|
|
||||||
return (*f)(as...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Application<true>
|
|
||||||
{
|
|
||||||
template <class OpFunction, typename... Ts>
|
|
||||||
static inline auto apply(std::shared_ptr<OpFunction> f, Ts... as)
|
|
||||||
-> decltype(OpFunction::apply(as...))
|
|
||||||
{
|
|
||||||
return OpFunction::apply(as...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
struct PackNum
|
struct PackNum
|
||||||
{
|
{
|
||||||
|
@ -174,8 +151,12 @@ namespace MultiArrayHelper
|
||||||
typedef typename std::remove_reference<decltype(std::get<0>(ops))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<0>(ops))>::type NextOpType;
|
||||||
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
||||||
static_assert(NEXT == 0, "inconsistent array positions");
|
static_assert(NEXT == 0, "inconsistent array positions");
|
||||||
typedef decltype(std::get<0>(ops).get(getX<0>( pos ))) ArgT;
|
if constexpr(OpFunction::FISSTATIC){
|
||||||
return Application<OpFunction::FISSTATIC>::template apply<OpFunction,ArgT,Args...>(f, std::get<0>(ops).get(getX<0>( pos )), args...);
|
return OpFunction::apply(std::get<0>(ops).get(getX<0>( pos )), args...);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (*f)(std::get<0>(ops).get(getX<0>( pos )), args...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t LAST, typename V, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
template <size_t LAST, typename V, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
||||||
|
@ -184,8 +165,12 @@ namespace MultiArrayHelper
|
||||||
typedef typename std::remove_reference<decltype(std::get<0>(ops))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<0>(ops))>::type NextOpType;
|
||||||
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
||||||
static_assert(NEXT == 0, "inconsistent array positions");
|
static_assert(NEXT == 0, "inconsistent array positions");
|
||||||
typedef decltype(std::get<0>(ops).template vget<V>(getX<0>( pos ))) ArgT;
|
if constexpr(OpFunction::FISSTATIC){
|
||||||
return Application<OpFunction::FISSTATIC>::template apply<OpFunction,ArgT,Args...>(f, std::get<0>(ops).template vget<V>(getX<0>( pos )), args...);
|
return OpFunction::apply(std::get<0>(ops).template vget<V>(getX<0>( pos )), args...);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (*f)(std::get<0>(ops).template vget<V>(getX<0>( pos )), args...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OpTuple, class Expr>
|
template <class OpTuple, class Expr>
|
||||||
|
|
Loading…
Reference in a new issue