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

[tuple.helper, pair.astuple, array.tuple] Unconventional description of tuple_element #2476

Closed
JohelEGP opened this issue Nov 16, 2018 · 5 comments

Comments

@JohelEGP
Copy link
Contributor

These use the Requires: element which, according to [structure.specifications], are for describing function semantics. They also use unconventional Type: and Value: elements.

array's description can be done following the conventions:

template<size_t I, class T, size_t N>
  struct tuple_element<I, array<T, N>> {
    using type = T;
  };

I < N shall be true.

As they are, there is no conventional space for the description of the type member of the partial specializations for tuple and pair. pair's could be elevated from english wording to code, as in using type = conditional_t<I == 0, T1, T2>;.

See https://wg21.link/tuple.helper, https://wg21.link/pair.astuple and https://wg21.link/array.tuple.

draft/source/utilities.tex

Lines 1792 to 1810 in 6a4eb32

\indexlibrary{\idxcode{tuple_element}}%
\begin{itemdecl}
template<size_t I, class... Types>
class tuple_element<I, tuple<Types...>> {
public:
using type = TI;
};
\end{itemdecl}
\begin{itemdescr}
\pnum
\requires \tcode{I < sizeof...(Types)}.
The program is ill-formed if \tcode{I} is out of bounds.
\pnum
\ctype \tcode{TI} is the
type of the $\tcode{I}^\text{th}$ element of \tcode{Types},
where indexing is zero-based.
\end{itemdescr}

draft/source/utilities.tex

Lines 885 to 895 in 6a4eb32

\indexlibrary{\idxcode{tuple_element}}%
\begin{itemdecl}
tuple_element<I, pair<T1, T2>>::type
\end{itemdecl}
\begin{itemdescr}
\pnum
\requires \tcode{I < 2}. The program is ill-formed if \tcode{I} is out of bounds.
\pnum
\textit{Value:} The type \tcode{T1} if \tcode{I == 0}, otherwise the type \tcode{T2}.
\end{itemdescr}

draft/source/containers.tex

Lines 3400 to 3411 in 6a4eb32

\indexlibrary{\idxcode{tuple_element}}%
\begin{itemdecl}
tuple_element<I, array<T, N>>::type
\end{itemdecl}
\begin{itemdescr}
\pnum
\requires \tcode{I < N}. The program is ill-formed if \tcode{I} is out of bounds.
\pnum
\cvalue The type T.
\end{itemdescr}

@JohelEGP
Copy link
Contributor Author

Just noticed https://wg21.link/LWG3166, which is about the Value: part of this issue.

@JohelEGP
Copy link
Contributor Author

I missed that these definitions are not enclosed in a namespace. Which is fine, since they are not meant to be instantiated as objects. But I still need to enclose them when documenting my own partial specializations depending on my program-defined types.

@JohelEGP
Copy link
Contributor Author

tuple_size similarly uses a Remarks: element.

@JohelEGP
Copy link
Contributor Author

https://wg21.link/LWG3193 generalizes this and other linked issues.

@jensmaurer
Copy link
Member

Duplicate of #2786.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants