3 ms·
Pretty please. [&]<std::size_t... I>(std::index_sequence<I...>) { (SetupInput<I>(options, transport_manager, subscriber_queues[I], thread_pool, templ
by a_t48 2y ago
Pretty please.
[&]<std::size_t... I>(std::index_sequence<I...>) {
(SetupInput<I>(options, transport_manager, subscriber_queues[I], thread_pool, templated_topic_to_runtime_topic),
...);
}(std::make_index_sequence<INPUT_COUNT>());
would be a lot more readible as
for constexpr( size_t I = 0; I < INPUT_COUNT; I++ )
SetupInput<I>(options, transport_manager, subscriber_queues[I], thread_pool, templated_topic_to_runtime_topic);
}
Yes, there's some syntax snags around it (right now I looks mutable, something like `for (constexpr size_t I : INPUT_COUNT)` might be better), but there has to be some sane middleground.
- moonshadow565 2y agoP1061 is in C++26 so you can instead do: const auto [...I] = std::make_index_sequence<INPUT_COUNT>{}; ((SetupInput<I>(options, transport_manager, subscriber_queues[I], thread_pool, templated_topic_to_runtime_topic)),...); yay!
- spacechild1 2y ago> right now I looks mutable, something like `for (constexpr size_t I : INPUT_COUNT)` might be better I thought the same, but then you lose the ability to control the increment step. For example, one might want to iterate pairwise. Regarding syntax, you could mandate that the loop variable has to be declared `constexpr` as well, which makes it clear that it can't be modified in the loop body.
- a_t48 2y agoYou could make a temporary or use some std::range/span helper. Double constexpr would work, too. Feels gross in the same way template template does.