7

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

Tom Huntington
  • 2,260
  • 10
  • 20

1 Answers1

9

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982