Skip to content

Commit a2f1d73

Browse files
committed
P1789R3 Library Support for Expansion Statements
1 parent f2b0254 commit a2f1d73

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

source/meta.tex

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,48 @@
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+
86+
template<size_t I, class T, T... Values>
87+
struct tuple_element<I, const integer_sequence<T, Values...>> {
88+
using type = T;
89+
};
90+
\end{itemdecl}
91+
92+
\begin{itemdescr}
93+
\pnum
94+
\mandates
95+
$\tcode{I} < \tcode{sizeof...(Values)}$.
96+
\end{itemdescr}
97+
98+
\indexlibrarymember{get}{integer_sequence}%
99+
\begin{itemdecl}
100+
template<size_t I, class T, T... Values>
101+
constexpr T get(integer_sequence<T, Values...>) noexcept;
102+
\end{itemdecl}
103+
104+
\begin{itemdescr}
105+
\pnum
106+
\mandates
107+
$\tcode{I} < \tcode{sizeof...(Values)}$.
108+
109+
\pnum
110+
\returns
111+
$\tcode{Values...[I]}$.
112+
\end{itemdescr}
113+
72114
\rSec1[type.traits]{Metaprogramming and type traits}
73115

74116
\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: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@
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 for \tcode{integer_sequence}
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+
127+
template<size_t I, class T, T... Values>
128+
struct tuple_element<I, const integer_sequence<T, Values...>>;
129+
130+
template<size_t I, class T, T... Values>
131+
constexpr T get(integer_sequence<T, Values...>) noexcept;
132+
117133
// \ref{pairs}, class template \tcode{pair}
118134
template<class T1, class T2>
119135
struct pair;
@@ -151,9 +167,6 @@
151167
constexpr @\seebelow@ make_pair(T1&&, T2&&);
152168

153169
// \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-
157170
template<class T1, class T2> struct tuple_size<pair<T1, T2>>;
158171
template<size_t I, class T1, class T2> struct tuple_element<I, pair<T1, T2>>;
159172

0 commit comments

Comments
 (0)