@@ -136,23 +136,16 @@ namespace ffi {
136136namespace details {
137137
138138// for each iterator
139- template <bool stop, std::size_t I, typename F>
140139struct for_each_dispatcher {
141- template <typename T, typename ... Args>
142- static void run (const F& f, T&& value, Args&&... args) { // NOLINT(*)
143- f (I, std::forward<T>(value));
144- for_each_dispatcher<sizeof ...(Args) == 0 , (I + 1 ), F>::run (f, std::forward<Args>(args)...);
140+ template <typename F, typename ... Args, size_t ... I>
141+ static void run (std::index_sequence<I...>, const F& f, Args&&... args) { // NOLINT(*)
142+ (f (I, std::forward<Args>(args)), ...);
145143 }
146144};
147145
148- template <std::size_t I, typename F>
149- struct for_each_dispatcher <true , I, F> {
150- static void run (const F&) {} // NOLINT(*)
151- };
152-
153146template <typename F, typename ... Args>
154147void for_each (const F& f, Args&&... args) { // NOLINT(*)
155- for_each_dispatcher< sizeof ...(Args) == 0 , 0 , F>:: run ( f, std::forward<Args>(args)...);
148+ for_each_dispatcher::run (std::index_sequence_for<Args ...>{}, f, std::forward<Args>(args)...);
156149}
157150
158151/* !
0 commit comments