Skip to content

Commit 7688f89

Browse files
committed
P1789R3 Library Support for Expansion Statements
Also fixes NB IT-002, NB FR-007-011, NB CZ 2-143, NB US 78-144 (C++26 CD).
1 parent f2b0254 commit 7688f89

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

source/meta.tex

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,47 @@
6969
\end{note}
7070
\end{itemdescr}
7171

72+
\rSec2[intseq.binding]{Structured binding support}
73+
74+
\indexlibraryglobal{tuple_size}%
75+
\indexlibraryglobal{tuple_element}%
76+
\begin{itemdecl}
77+
template<class T, T... Values>
78+
struct tuple_size<integer_sequence<T, Values...>>
79+
: integral_constant<size_t, sizeof...(Values)> { };
80+
81+
template<size_t I, class T, T... Values>
82+
struct tuple_element<I, integer_sequence<T, Values...>> {
83+
using type = T;
84+
};
85+
template<size_t I, class T, T... Values>
86+
struct tuple_element<I, const integer_sequence<T, Values...>> {
87+
using type = T;
88+
};
89+
\end{itemdecl}
90+
91+
\begin{itemdescr}
92+
\pnum
93+
\mandates
94+
$\tcode{I} < \tcode{sizeof...(Values)}$.
95+
\end{itemdescr}
96+
97+
\indexlibrarymember{get}{integer_sequence}%
98+
\begin{itemdecl}
99+
template<size_t I, class T, T... Values>
100+
constexpr T get(integer_sequence<T, Values...>) noexcept;
101+
\end{itemdecl}
102+
103+
\begin{itemdescr}
104+
\pnum
105+
\mandates
106+
$\tcode{I} < \tcode{sizeof...(Values)}$.
107+
108+
\pnum
109+
\returns
110+
\tcode{Values...[I]}.
111+
\end{itemdescr}
112+
72113
\rSec1[type.traits]{Metaprogramming and type traits}
73114

74115
\rSec2[type.traits.general]{General}

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@
725725
#define @\defnlibxname{cpp_lib_inplace_vector}@ 202406L // also in \libheader{inplace_vector}
726726
#define @\defnlibxname{cpp_lib_int_pow2}@ 202002L // freestanding, also in \libheader{bit}
727727
#define @\defnlibxname{cpp_lib_integer_comparison_functions}@ 202002L // also in \libheader{utility}
728-
#define @\defnlibxname{cpp_lib_integer_sequence}@ 201304L // freestanding, also in \libheader{utility}
728+
#define @\defnlibxname{cpp_lib_integer_sequence}@ 202511L // freestanding, also in \libheader{utility}
729729
#define @\defnlibxname{cpp_lib_integral_constant_callable}@ 201304L // freestanding, also in \libheader{type_traits}
730730
#define @\defnlibxname{cpp_lib_interpolate}@ 201902L // also in \libheader{cmath}, \libheader{numeric}
731731
#define @\defnlibxname{cpp_lib_invoke}@ 201411L // freestanding, also in \libheader{functional}

source/utilities.tex

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@
114114
template<class... T>
115115
using index_sequence_for = make_index_sequence<sizeof...(T)>;
116116

117+
template<class T> struct tuple_size;
118+
template<size_t I, class T> struct tuple_element;
119+
120+
// \ref{intseq.binding}, structured binding support
121+
template<class T, T... Values>
122+
struct tuple_size<integer_sequence<T, Values...>>;
123+
124+
template<size_t I, class T, T... Values>
125+
struct tuple_element<I, integer_sequence<T, Values...>>;
126+
template<size_t I, class T, T... Values>
127+
struct tuple_element<I, const integer_sequence<T, Values...>>;
128+
129+
template<size_t I, class T, T... Values>
130+
constexpr T get(integer_sequence<T, Values...>) noexcept;
131+
117132
// \ref{pairs}, class template \tcode{pair}
118133
template<class T1, class T2>
119134
struct pair;
@@ -151,9 +166,6 @@
151166
constexpr @\seebelow@ make_pair(T1&&, T2&&);
152167

153168
// \ref{pair.astuple}, tuple-like access to pair
154-
template<class T> struct tuple_size;
155-
template<size_t I, class T> struct tuple_element;
156-
157169
template<class T1, class T2> struct tuple_size<pair<T1, T2>>;
158170
template<size_t I, class T1, class T2> struct tuple_element<I, pair<T1, T2>>;
159171

0 commit comments

Comments
 (0)