Skip to content
Snippets Groups Projects
Commit 3fec45ce authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/apply_for_variadic' into 'master'

extend apply and for_each functions

See merge request !43
parents 51fa4226 823cb0e4
1 merge request!43extend apply and for_each functions
......@@ -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,16 @@ namespace AMDiS
void ignored_evaluation(std::initializer_list<T>&&) { /* do nothing */ }
}
template <class Functor, class... Args>
constexpr void for_variadic(Functor&& f, Args&&... args)
{
#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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment