AutoPas  3.0.0
Loading...
Searching...
No Matches
TupleUtils.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <tuple>
10
12
21template <class T, class F>
22void for_each(T &&tuple, F &&f) {
23 std::apply(
24 // function that takes all elements of the tuple as variadic argument
25 [&](auto &...t) {
26 // unpack the tuple using a fold (... op pack) with op as the comma operator to apply a lambda on every element
27 // This will cause problems if anyone overloads the comma operator for elements of tuple!
28 (..., f(t));
29 },
30 tuple);
31}
32
33} // namespace autopas::utils::TupleUtils
In this namespace some helper functions for std::tuple can be found.
Definition: namespaces.h:75
void for_each(T &&tuple, F &&f)
Applies a function f on every element of the tuple.
Definition: TupleUtils.h:22