generalize operation types (func args and return types may be diffent now)
This commit is contained in:
parent
3b2889d38f
commit
3367ab684a
2 changed files with 15 additions and 11 deletions
|
@ -47,7 +47,7 @@ namespace MultiArrayTools
|
||||||
// EVALUTAION CLASS ??!!!!
|
// EVALUTAION CLASS ??!!!!
|
||||||
|
|
||||||
auto exec(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
auto exec(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||||
-> decltype( mkOperation( mFunc, ConstOperationRoot<T,SRanges>( indexToSlice( inds ), inds) ... ) );
|
-> decltype( mkOperation( mFunc, ConstOperationRoot<typename SRanges::IndexType::MetaType,SRanges>( indexToSlice( inds ), inds) ... ) );
|
||||||
|
|
||||||
virtual ConstOperationRoot<T,SRanges...>
|
virtual ConstOperationRoot<T,SRanges...>
|
||||||
operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
|
operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
|
||||||
|
@ -157,9 +157,9 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Function, class... SRanges>
|
template <typename T, class Function, class... SRanges>
|
||||||
auto FunctionalMultiArray<T,Function,SRanges...>::
|
auto FunctionalMultiArray<T,Function,SRanges...>::
|
||||||
exec(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
exec(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||||
-> decltype( mkOperation( mFunc, ConstOperationRoot<T,SRanges>( indexToSlice( inds ), inds) ... ) )
|
-> decltype( mkOperation( mFunc, ConstOperationRoot<typename SRanges::IndexType::MetaType,SRanges>( indexToSlice( inds ), inds) ... ) )
|
||||||
{
|
{
|
||||||
return mkOperation( mFunc, ConstOperationRoot<T,SRanges>( indexToSlice( inds ), inds ) ... );
|
return mkOperation( mFunc, ConstOperationRoot<typename SRanges::IndexType::MetaType,SRanges>( indexToSlice( inds ), inds ) ... );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,20 +16,22 @@ namespace MultiArrayHelper
|
||||||
template <bool ISSTATIC>
|
template <bool ISSTATIC>
|
||||||
struct Application
|
struct Application
|
||||||
{
|
{
|
||||||
template <class OpFunction, typename T, typename... Ts>
|
template <class OpFunction, typename... Ts>
|
||||||
static inline T apply(std::shared_ptr<OpFunction> f, T a, Ts... as)
|
static inline auto apply(std::shared_ptr<OpFunction> f, Ts... as)
|
||||||
|
-> decltype((*f)(as...))
|
||||||
{
|
{
|
||||||
return (*f)(a, as...);
|
return (*f)(as...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Application<true>
|
struct Application<true>
|
||||||
{
|
{
|
||||||
template <class OpFunction, typename T, typename... Ts>
|
template <class OpFunction, typename... Ts>
|
||||||
static inline T apply(std::shared_ptr<OpFunction> f, T a, Ts... as)
|
static inline auto apply(std::shared_ptr<OpFunction> f, Ts... as)
|
||||||
|
-> decltype(OpFunction::apply(as...))
|
||||||
{
|
{
|
||||||
return OpFunction::apply(a, as...);
|
return OpFunction::apply(as...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +76,8 @@ namespace MultiArrayHelper
|
||||||
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;
|
||||||
return PackNum<N-1>::template mkOpExpr<NEXT,T,ETuple,OpTuple,OpFunction,T,Args...>
|
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...>
|
||||||
( f, pos, ops, std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos )), args...);
|
( f, pos, ops, std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos )), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +139,8 @@ 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");
|
||||||
return Application<OpFunction::FISSTATIC>::apply(f, std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
typedef decltype(std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos ))) ArgT;
|
||||||
|
return Application<OpFunction::FISSTATIC>::template apply<OpFunction,ArgT,Args...>(f, std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
||||||
//return OpFunction::apply(std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
//return OpFunction::apply(std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue