r/cpp • • Apr 24 '26

C++26: Structured Bindings can introduce a Pack

https://www.sandordargo.com/blog/2026/04/22/cpp26-structured-bindings-packs
102 Upvotes

40 comments sorted by

View all comments

Show parent comment

4

u/slithering3897 Apr 24 '26

Vectors from reflection maybe. std::define_static_array would almost get you there, but the span is not statically sized.

3

u/friedkeenan Apr 24 '26 edited Apr 24 '26

There’s std::meta::reflect_constant_array which will yield a reflection of a C array which you can then splice in and get structured bindings from.

EDIT: Here's an example: https://godbolt.org/z/4q37o6E4a