Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LWG 14] P2819R2 Add tuple protocol to complex #6693

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions source/numerics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,20 @@
template<class T> constexpr complex<T> tan (const complex<T>&);
template<class T> constexpr complex<T> tanh (const complex<T>&);

// \ref{complex.tuple}, tuple interface
template<class T> struct tuple_size;
template<size_t I, class T> struct tuple_element;
template<class T> struct tuple_size<complex<T>>;
template<size_t I, class T> struct tuple_element<I, complex<T>>;
template<size_t I, class T>
constexpr T& get(complex<T>&) noexcept;
template<size_t I, class T>
constexpr T&& get(complex<T>&&) noexcept;
template<size_t I, class T>
constexpr const T& get(const complex<T>&) noexcept;
template<size_t I, class T>
constexpr const T&& get(const complex<T>&&) noexcept;

// \ref{complex.literals}, complex literals
inline namespace literals {
inline namespace complex_literals {
Expand Down Expand Up @@ -1121,6 +1135,49 @@
The complex hyperbolic tangent of \tcode{x}.
\end{itemdescr}

\rSec2[complex.tuple]{Tuple interface}

\indexlibraryglobal{tuple_size}%
\indexlibraryglobal{tuple_element}%
\begin{itemdecl}
template<class T>
struct tuple_size<complex<T>> : integral_constant<size_t, 2> {};

template<size_t I, class T>
struct tuple_element<I, complex<T>> {
using type = T;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\mandates
\tcode{I < 2} is \tcode{true}.
\end{itemdescr}

\indexlibrarymember{get}{complex}%
\begin{itemdecl}
template<size_t I, class T>
constexpr T& get(complex<T>& z) noexcept;
template<size_t I, class T>
constexpr T&& get(complex<T>&& z) noexcept;
template<size_t I, class T>
constexpr const T& get(const complex<T>& z) noexcept;
template<size_t I, class T>
constexpr const T&& get(const complex<T>&& z) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\mandates
\tcode{I < 2} is \tcode{true}.

\pnum
\returns
A reference to the real part of \tcode{z} if \tcode{I == 0} is \tcode{true},
otherwise a reference to the imaginary part of \tcode{z}.
\end{itemdescr}

\rSec2[cmplx.over]{Additional overloads}

\pnum
Expand Down
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
#define @\defnlibxname{cpp_lib_transparent_operators}@ 201510L
// freestanding, also in \libheader{memory}, \libheader{functional}
#define @\defnlibxname{cpp_lib_tuple_element_t}@ 201402L // freestanding, also in \libheader{tuple}
#define @\defnlibxname{cpp_lib_tuple_like}@ 202207L
#define @\defnlibxname{cpp_lib_tuple_like}@ 202311L
// also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map}
#define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple}
#define @\defnlibxname{cpp_lib_type_identity}@ 201806L // freestanding, also in \libheader{type_traits}
Expand Down
2 changes: 1 addition & 1 deletion source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@
A type \tcode{T} models and satisfies
the exposition-only concept \exposconcept{tuple-like}
if \tcode{remove_cvref_t<T>} is a specialization of
\tcode{array}, \tcode{pair}, \tcode{tuple}, or \tcode{ranges::subrange}.
\tcode{array}, \tcode{complex}, \tcode{pair}, \tcode{tuple}, or \tcode{ranges::subrange}.
\end{itemdescr}

\rSec2[tuple.tuple]{Class template \tcode{tuple}}
Expand Down