Re:C++26: Pack Indexing
by a_t48 on Friday January 24, 2025 @03:32PM
(#42816640)
Pretty please.
would be a lot more readible as
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.
[ Parent
| on HN ]
Re:C++26: Pack Indexing
by moonshadow565 on Friday January 24, 2025 @04:18PM
(#42817018)
P1061 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!Oh, that is nice!
That's better, yeah. I still prefer plain ole for loops, but that's much better.
Re:C++26: Pack Indexing
by spacechild1 on Friday January 24, 2025 @04:37PM
(#42817159)
> 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.