C++ Logo

std-discussion

Advanced search

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

From: Abhinav Agarwal <abhinavagarwal1996_at_[hidden]>
Date: Fri, 20 Mar 2026 02:02:27 -0700
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)

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:02:56