C++ Logo

std-discussion

Advanced search

Re: [dcl.struct.bind] wrong index with structured binding packs

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Fri, 20 Mar 2026 10:26:00 +0100
Please post an editorial pull request.

Thanks,
Jens


On 3/20/26 10:02, Abhinav Agarwal via Std-Discussion wrote:
> Hi,
>
> [dcl.struct.bind] p7 (tuple-like case) says:
>
> "Let i be an index prvalue of type std::size_t corresponding to v_i."
> (https://eel.is/c++draft/dcl.struct.bind#7 <https://eel.is/c++draft/dcl.struct.bind#7>)
>
> This should be SB_i, not v_i. With a structured binding pack, v_i indexes the pre-expansion sb-identifiers, so bindings after the pack get the wrong index for get<i>(). For example, with auto [a, ...b, c] = tuple<int,int,int,int>{1,2,3,4}, c ends up corresponding to v_2 instead of SB_3, so it gets initialized from get<2>(e) (value 3) instead of get<3>(e) (value 4).
>
> The rest of the section already uses SB_i — p6, p8, and even the end of this same paragraph ("Each SB_i is the name of...") all use SB_i. Looks like this one sentence wasn't updated when P1061 introduced the SB_i notation.
>
> Is this already known? I couldn't find anything.
>
> Thanks,
> Abhinav Agarwal
>

Received on 2026-03-20 09:26:07