Commit 19935161 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

extend apply and for_each functions

parent 2c7ee1ed
......@@ -41,6 +41,13 @@ namespace AMDiS
return apply(FWD(f), std::forward_as_tuple(args...));
}
template <std::size_t N, class Functor>
constexpr decltype(auto) apply_indices(Functor&& f)
{
return Impl_::apply_indices_impl(FWD(f), index_t<0>{},
std::make_index_sequence<N>{});
}
template <class Functor, std::size_t N>
constexpr decltype(auto) apply_indices(Functor&& f, index_t<N>)
{
......
......@@ -15,6 +15,17 @@ namespace AMDiS
void ignored_evaluation(std::initializer_list<T>&&) { /* do nothing */ }
}
template <class Functor, class... Args>
constexpr void for_variadic(Functor&& f, Args&&... args)
{
using std::get;
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(f(FWD(args)),...);
#else
Impl_::ignored_evaluation<int>({0, (f(FWD(args)), 0)...});
#endif
}
template <std::size_t... I, class Tuple, class Functor>
constexpr void for_each(std::index_sequence<I...>, Tuple&& tuple, Functor&& f)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment