structured binding with [[maybe_unused]]

In the structure bindings paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0144r2.pdf they discuss their reasoning: 3.8 Should there be a way to explicitly ignore components? The motivation would be to silence compiler warnings about unused names. We think the answer should be “not yet.” This is not motivated by use cases (silencing compiler warnings is a motivation, but it is … Read more

std::ignore with structured bindings?

The structured bindings proposal contains a dedicated section answering your question (P0144R2): 3.8 Should there be a way to explicitly ignore components? The motivation would be to silence compiler warnings about unused names. We think the answer should be “not yet.” This is not motivated by use cases (silencing compiler warnings is a motivation, but … Read more

structured bindings: when something looks like a reference and behaves similarly to a reference, but it’s not a reference

I wrote this yesterday: decltype(x), where x is a structured binding, names the referenced type of that structured binding. In the tuple-like case, this is the type returned by std::tuple_element, which may not be a reference even though the structured binding itself is in fact always a reference in this case. This effectively emulates the … Read more

Lambda implicit capture fails with variable declared from structured binding

Core issue 2313 changed the standard so that structured bindings are never names of variables, making them never capturable. P0588R1‘s reformulation of lambda capture wording makes this prohibition explicit: If a lambda-expression […] captures a structured binding (explicitly or implicitly), the program is ill-formed. Note that this wording is supposedly a placeholder while the committee … Read more