#ifndef __PLASP_APP__UTILS_H #define __PLASP_APP__UTILS_H #include //////////////////////////////////////////////////////////////////////////////////////////////////// // // Command // //////////////////////////////////////////////////////////////////////////////////////////////////// template auto makeIndexDispatcher(std::index_sequence) { return [](auto &&f) { (f(std::integral_constant{}), ...); }; } //////////////////////////////////////////////////////////////////////////////////////////////////// template auto makeIndexDispatcher() { return makeIndexDispatcher(std::make_index_sequence{}); } //////////////////////////////////////////////////////////////////////////////////////////////////// template void forEach(Tuple &&tuple, Functor &&functor) { constexpr auto n = std::tuple_size>::value; auto dispatcher = makeIndexDispatcher(); dispatcher( [&functor, &tuple](auto index) { functor(std::get(std::forward(tuple))); }); } //////////////////////////////////////////////////////////////////////////////////////////////////// #endif