Structured binding for fixed-size span

238 views Asked by At

After finding out you can ergonomically convert std::vectors into fix-sized std::spans, I thought I'd try out structured bindings for std::vector:

auto _ = std::vector{ 1,2,3 };
std::span<int, 3> a = std::span(_).first<3>();
auto [b,c,d] = a;

But it's not working https://godbolt.org/z/nhrYn65dW

However, it seems from P1024 Usability Enhancements for std::span which was accepted that this should be legal

Add structured binding support for fixed-size span? Unanimous consent

1

There are 1 answers

0
Nicol Bolas On BEST ANSWER

This part of P1024 was undone by P2116. The reasoning comes from LWG issue 3212, which details issues around the way span would need to interact with with const in a tuple-like interface. After some attempts at reworking the idea, they just decided to remove it.