diff --git a/include/ircd/util.h b/include/ircd/util.h index 3d0f15f5c..c88a405fa 100644 --- a/include/ircd/util.h +++ b/include/ircd/util.h @@ -120,6 +120,31 @@ template using custom_ptr = std::unique_ptr>; +// +// Iteration of a tuple +// +// for_each(tuple, [](auto&& elem) { ... }); + +template +typename std::enable_if>::value, void>::type +for_each(const std::tuple &t, + func&& f) +{} + +template +typename std::enable_if>::value, void>::type +for_each(const std::tuple &t, + func&& f) +{ + f(std::get(t)); + for_each(t, std::forward(f)); +} + + // For conforming enums include a _NUM_ as the last element, // then num_of() works template