Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52d8bd6

Browse filesBrowse files
authored
Merge 2023-11 LWG Motion 14
P2819R2 Add tuple protocol to complex
2 parents bff0d08 + acf66d8 commit 52d8bd6
Copy full SHA for 52d8bd6

File tree

3 files changed

+59
-2
lines changed
Filter options

3 files changed

+59
-2
lines changed

‎source/numerics.tex

Copy file name to clipboardExpand all lines: source/numerics.tex
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@
289289
template<class T> constexpr complex<T> tan (const complex<T>&);
290290
template<class T> constexpr complex<T> tanh (const complex<T>&);
291291

292+
// \ref{complex.tuple}, tuple interface
293+
template<class T> struct tuple_size;
294+
template<size_t I, class T> struct tuple_element;
295+
template<class T> struct tuple_size<complex<T>>;
296+
template<size_t I, class T> struct tuple_element<I, complex<T>>;
297+
template<size_t I, class T>
298+
constexpr T& get(complex<T>&) noexcept;
299+
template<size_t I, class T>
300+
constexpr T&& get(complex<T>&&) noexcept;
301+
template<size_t I, class T>
302+
constexpr const T& get(const complex<T>&) noexcept;
303+
template<size_t I, class T>
304+
constexpr const T&& get(const complex<T>&&) noexcept;
305+
292306
// \ref{complex.literals}, complex literals
293307
inline namespace literals {
294308
inline namespace complex_literals {
@@ -1121,6 +1135,49 @@
11211135
The complex hyperbolic tangent of \tcode{x}.
11221136
\end{itemdescr}
11231137

1138+
\rSec2[complex.tuple]{Tuple interface}
1139+
1140+
\indexlibraryglobal{tuple_size}%
1141+
\indexlibraryglobal{tuple_element}%
1142+
\begin{itemdecl}
1143+
template<class T>
1144+
struct tuple_size<complex<T>> : integral_constant<size_t, 2> {};
1145+
1146+
template<size_t I, class T>
1147+
struct tuple_element<I, complex<T>> {
1148+
using type = T;
1149+
};
1150+
\end{itemdecl}
1151+
1152+
\begin{itemdescr}
1153+
\pnum
1154+
\mandates
1155+
\tcode{I < 2} is \tcode{true}.
1156+
\end{itemdescr}
1157+
1158+
\indexlibrarymember{get}{complex}%
1159+
\begin{itemdecl}
1160+
template<size_t I, class T>
1161+
constexpr T& get(complex<T>& z) noexcept;
1162+
template<size_t I, class T>
1163+
constexpr T&& get(complex<T>&& z) noexcept;
1164+
template<size_t I, class T>
1165+
constexpr const T& get(const complex<T>& z) noexcept;
1166+
template<size_t I, class T>
1167+
constexpr const T&& get(const complex<T>&& z) noexcept;
1168+
\end{itemdecl}
1169+
1170+
\begin{itemdescr}
1171+
\pnum
1172+
\mandates
1173+
\tcode{I < 2} is \tcode{true}.
1174+
1175+
\pnum
1176+
\returns
1177+
A reference to the real part of \tcode{z} if \tcode{I == 0} is \tcode{true},
1178+
otherwise a reference to the imaginary part of \tcode{z}.
1179+
\end{itemdescr}
1180+
11241181
\rSec2[cmplx.over]{Additional overloads}
11251182

11261183
\pnum

‎source/support.tex

Copy file name to clipboardExpand all lines: source/support.tex
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@
787787
#define @\defnlibxname{cpp_lib_transparent_operators}@ 201510L
788788
// freestanding, also in \libheader{memory}, \libheader{functional}
789789
#define @\defnlibxname{cpp_lib_tuple_element_t}@ 201402L // freestanding, also in \libheader{tuple}
790-
#define @\defnlibxname{cpp_lib_tuple_like}@ 202207L
790+
#define @\defnlibxname{cpp_lib_tuple_like}@ 202311L
791791
// also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map}
792792
#define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple}
793793
#define @\defnlibxname{cpp_lib_type_identity}@ 201806L // freestanding, also in \libheader{type_traits}

‎source/utilities.tex

Copy file name to clipboardExpand all lines: source/utilities.tex
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@
16121612
A type \tcode{T} models and satisfies
16131613
the exposition-only concept \exposconcept{tuple-like}
16141614
if \tcode{remove_cvref_t<T>} is a specialization of
1615-
\tcode{array}, \tcode{pair}, \tcode{tuple}, or \tcode{ranges::subrange}.
1615+
\tcode{array}, \tcode{complex}, \tcode{pair}, \tcode{tuple}, or \tcode{ranges::subrange}.
16161616
\end{itemdescr}
16171617

16181618
\rSec2[tuple.tuple]{Class template \tcode{tuple}}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.