-
Notifications
You must be signed in to change notification settings - Fork 804
P3016R6 Resolve inconsistencies in begin/end for valarray and braced initializer lists #8544
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
Open
AlisdairM
wants to merge
3
commits into
cplusplus:main
Choose a base branch
from
AlisdairM:p3016r6_inconsistent_begin_end
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+154
−130
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |||||||||
| \begin{codeblock} | ||||||||||
| #include <compare> // see \ref{compare.syn} | ||||||||||
| #include <concepts> // see \ref{concepts.syn} | ||||||||||
| #include <initializer_list> // see \ref{initializer.list.syn} | ||||||||||
|
|
||||||||||
| namespace std { | ||||||||||
| template<class T> using @\exposid{with-reference}@ = T&; // \expos | ||||||||||
|
|
@@ -464,53 +465,64 @@ | |||||||||
| class ostreambuf_iterator; | ||||||||||
|
|
||||||||||
| // \ref{iterator.range}, range access | ||||||||||
| template<class C> constexpr auto begin(C& c) -> decltype(c.begin()); // freestanding | ||||||||||
| template<class C> constexpr auto begin(const C& c) -> decltype(c.begin()); // freestanding | ||||||||||
| template<class C> constexpr auto end(C& c) -> decltype(c.end()); // freestanding | ||||||||||
| template<class C> constexpr auto end(const C& c) -> decltype(c.end()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| begin(C& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| begin(const C& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| end(C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| end(const C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class C> constexpr auto cbegin(const C& c) // freestanding | ||||||||||
| noexcept(noexcept(std::begin(c))) -> decltype(std::begin(c)); | ||||||||||
| template<class C> constexpr auto cend(const C& c) // freestanding | ||||||||||
| noexcept(noexcept(std::end(c))) -> decltype(std::end(c)); | ||||||||||
| template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin()); // freestanding | ||||||||||
| template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin()); // freestanding | ||||||||||
| template<class C> constexpr auto rend(C& c) -> decltype(c.rend()); // freestanding | ||||||||||
| template<class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]) // freestanding | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| cbegin(const C& c) noexcept(noexcept(std::begin(c))) | ||||||||||
| -> decltype(std::begin(c)); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| cend(const C& c) noexcept(noexcept(std::end(c))) -> decltype(std::end(c)); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| rbegin(C& c) noexcept(noexcept(c.rbegin())) -> decltype(c.rbegin()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| rbegin(const C& c) noexcept(noexcept(c.rbegin())) -> decltype(c.rbegin()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| rend(C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| rend(const C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> | ||||||||||
| rbegin(T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> | ||||||||||
| rend(T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> | ||||||||||
| rbegin(initializer_list<E> il); // freestanding | ||||||||||
| rbegin(initializer_list<E> il) noexcept; // freestanding | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> | ||||||||||
| rend(initializer_list<E> il); // freestanding | ||||||||||
| rend(initializer_list<E> il) noexcept; // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| crbegin(const C& c) -> decltype(std::rbegin(c)); // freestanding | ||||||||||
| crbegin(const C& c) noexcept(noexcept(std::rbegin(c))) | ||||||||||
| -> decltype(std::rbegin(c)); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| crend(const C& c) -> decltype(std::rend(c)); // freestanding | ||||||||||
| crend(const C& c) noexcept(noexcept(std::rend(c))) -> decltype(std::rend(c)); // freestanding | ||||||||||
|
|
||||||||||
| template<class C> constexpr auto | ||||||||||
| size(const C& c) -> decltype(c.size()); // freestanding | ||||||||||
| size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr size_t | ||||||||||
| size(const T (&array)[N]) noexcept; // freestanding | ||||||||||
|
|
||||||||||
| template<class C> constexpr auto | ||||||||||
| ssize(const C& c) | ||||||||||
| ssize(const C& c) noexcept(noexcept(c.size())) | ||||||||||
| -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // freestanding | ||||||||||
| template<class T, ptrdiff_t N> constexpr ptrdiff_t | ||||||||||
| ssize(const T (&array)[N]) noexcept; // freestanding | ||||||||||
|
|
||||||||||
| template<class C> constexpr auto | ||||||||||
| empty(const C& c) -> decltype(c.empty()); // freestanding | ||||||||||
| empty(const C& c) noexcept(noexcept(c.empty())) -> decltype(c.empty()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr bool | ||||||||||
| empty(const T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class E> constexpr bool | ||||||||||
| empty(initializer_list<E> il) noexcept; // freestanding | ||||||||||
|
|
||||||||||
| template<class C> constexpr auto data(C& c) -> decltype(c.data()); // freestanding | ||||||||||
| template<class C> constexpr auto data(const C& c) -> decltype(c.data()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data()); // freestanding | ||||||||||
| template<class C> constexpr auto | ||||||||||
| data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data()); // freestanding | ||||||||||
| template<class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // freestanding | ||||||||||
| template<class E> constexpr const E* data(initializer_list<E> il) noexcept; // freestanding | ||||||||||
| } | ||||||||||
| \end{codeblock} | ||||||||||
|
|
||||||||||
|
|
@@ -7241,28 +7253,38 @@ | |||||||||
| In addition to being available via inclusion of the \libheader{iterator} header, | ||||||||||
| the function templates in \ref{iterator.range} are available when any of the following | ||||||||||
| headers are included: | ||||||||||
| \libheaderref{array}, | ||||||||||
| \libheaderref{deque}, | ||||||||||
| \libheaderrefx{flat_map}{flat.map.syn}, | ||||||||||
| \libheaderrefx{flat_set}{flat.set.syn}, | ||||||||||
| \libheaderrefx{forward_list}{forward.list.syn}, | ||||||||||
| \libheaderref{hive}, | ||||||||||
| \libheaderrefx{inplace_vector}{inplace.vector.syn}, | ||||||||||
| \libheaderref{list}, | ||||||||||
| \libheaderrefx{map}{associative.map.syn}, | ||||||||||
| \libheaderrefx{regex}{re.syn}, | ||||||||||
| \libheaderrefx{set}{associative.set.syn}, | ||||||||||
| \libheaderref{span}, | ||||||||||
| \libheaderref{string}, | ||||||||||
| \libheaderrefx{string_view}{string.view.synop}, | ||||||||||
| \libheaderrefx{unordered_map}{unord.map.syn}, | ||||||||||
| \libheaderrefx{unordered_set}{unord.set.syn}, and | ||||||||||
| \libheaderref{vector}. | ||||||||||
| \begin{multicolfloattable}{Additional range function headers}{range.function.headers} | ||||||||||
| {lll} | ||||||||||
| \libheaderref{array} \\ | ||||||||||
| \libheaderref{deque} \\ | ||||||||||
| \libheaderrefx{flat_map}{flat.map.syn} \\ | ||||||||||
| \libheaderrefx{flat_set}{flat.set.syn} \\ | ||||||||||
| \libheaderrefx{forward_list}{forward.list.syn} \\ | ||||||||||
| \libheaderref{hive} \\ | ||||||||||
| \libheaderrefx{inplace_vector}{inplace.vector.syn} \\ | ||||||||||
| \columnbreak | ||||||||||
| \libheaderref{list} \\ | ||||||||||
| \libheaderrefx{map}{associative.map.syn} \\ | ||||||||||
| \libheaderref{optional} \\ | ||||||||||
| \libheaderrefx{regex}{re.syn} \\ | ||||||||||
| \libheaderrefx{set}{associative.set.syn} \\ | ||||||||||
| \libheaderref{span} \\ | ||||||||||
| \libheaderref{stacktrace} \\ | ||||||||||
| \columnbreak | ||||||||||
| \libheaderref{string} \\ | ||||||||||
| \libheaderrefx{string_view}{string.view.synop} \\ | ||||||||||
| \libheaderrefx{unordered_map}{unord.map.syn} \\ | ||||||||||
| \libheaderrefx{unordered_set}{unord.set.syn} \\ | ||||||||||
| \libheaderref{valarray} \\ | ||||||||||
| \libheaderref{vector} \\ | ||||||||||
| \end{multicolfloattable} | ||||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{begin(C\&)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto begin(C& c) -> decltype(c.begin()); | ||||||||||
| template<class C> constexpr auto begin(const C& c) -> decltype(c.begin()); | ||||||||||
| template<class C> constexpr auto begin(C& c) noexcept(noexcept(c.begin())) | ||||||||||
| -> decltype(c.begin()); | ||||||||||
| template<class C> constexpr auto begin(const C& c) noexcept(noexcept(c.begin())) | ||||||||||
| -> decltype(c.begin()); | ||||||||||
| \end{itemdecl} | ||||||||||
|
|
||||||||||
| \begin{itemdescr} | ||||||||||
|
|
@@ -7273,8 +7295,8 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{end(C\&)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto end(C& c) -> decltype(c.end()); | ||||||||||
| template<class C> constexpr auto end(const C& c) -> decltype(c.end()); | ||||||||||
| template<class C> constexpr auto end(C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); | ||||||||||
| template<class C> constexpr auto end(const C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); | ||||||||||
| \end{itemdecl} | ||||||||||
|
|
||||||||||
| \begin{itemdescr} | ||||||||||
|
|
@@ -7329,8 +7351,10 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rbegin(C\&)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin()); | ||||||||||
| template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin()); | ||||||||||
| template<class C> constexpr auto rbegin(C& c) noexcept(noexcept(c.rbegin())) | ||||||||||
| -> decltype(c.rbegin()); | ||||||||||
| template<class C> constexpr auto rbegin(const C& c) noexcept(noexcept(c.rbegin())) | ||||||||||
| -> decltype(c.rbegin()); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7340,8 +7364,9 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rend(C\&)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto rend(C& c) -> decltype(c.rend()); | ||||||||||
| template<class C> constexpr auto rend(const C& c) -> decltype(c.rend()); | ||||||||||
| template<class C> constexpr auto rend(C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend()); | ||||||||||
| template<class C> constexpr auto rend(const C& c) noexcept(noexcept(c.rend())) | ||||||||||
| -> decltype(c.rend()); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7351,7 +7376,7 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rbegin(T (\&array)[N])}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]); | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7361,7 +7386,7 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rend(T (\&array)[N])}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]); | ||||||||||
| template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7371,7 +7396,7 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rbegin(initializer_list<E>)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il); | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7381,7 +7406,7 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{rend(initializer_list<E>)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il); | ||||||||||
| template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7391,7 +7416,8 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{crbegin(const C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); | ||||||||||
| template<class C> constexpr auto crbegin(const C& c) noexcept(noexcept(c.crbegin())) | ||||||||||
| -> decltype(std::rbegin(c)); | ||||||||||
|
Comment on lines
+7419
to
+7420
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same mistake of using the member functions instead of the |
||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7401,7 +7427,8 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{crend(const C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); | ||||||||||
| template<class C> constexpr auto crend(const C& c) noexcept(noexcept(c.crend())) | ||||||||||
| -> decltype(std::rend(c)); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7411,7 +7438,8 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{size(C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto size(const C& c) -> decltype(c.size()); | ||||||||||
| template<class C> constexpr auto size(const C& c) noexcept(noexcept(c.size())) | ||||||||||
| -> decltype(c.size()); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7431,7 +7459,7 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{ssize(C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto ssize(const C& c) | ||||||||||
| template<class C> constexpr auto ssize(const C& c) noexcept(noexcept(c.ssize())) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
|
|
@@ -7455,7 +7483,8 @@ | |||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{empty(C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto empty(const C& c) -> decltype(c.empty()); | ||||||||||
| template<class C> constexpr auto empty(const C& c) noexcept(noexcept(c.empty())) | ||||||||||
| -> decltype(c.empty()); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7473,20 +7502,11 @@ | |||||||||
| \tcode{false}. | ||||||||||
| \end{itemdescr} | ||||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{empty(initializer_list<E>)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class E> constexpr bool empty(initializer_list<E> il) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
| \returns | ||||||||||
| \tcode{il.size() == 0}. | ||||||||||
| \end{itemdescr} | ||||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{data(C\& c)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class C> constexpr auto data(C& c) -> decltype(c.data()); | ||||||||||
| template<class C> constexpr auto data(const C& c) -> decltype(c.data()); | ||||||||||
| template<class C> constexpr auto data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data()); | ||||||||||
| template<class C> constexpr auto data(const C& c) noexcept(noexcept(c.data())) | ||||||||||
| -> decltype(c.data()); | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
|
|
@@ -7503,13 +7523,3 @@ | |||||||||
| \returns | ||||||||||
| \tcode{array}. | ||||||||||
| \end{itemdescr} | ||||||||||
|
|
||||||||||
| \indexlibrary{\idxcode{data(initializer_list<E>)}}% | ||||||||||
| \begin{itemdecl} | ||||||||||
| template<class E> constexpr const E* data(initializer_list<E> il) noexcept; | ||||||||||
| \end{itemdecl} | ||||||||||
| \begin{itemdescr} | ||||||||||
| \pnum | ||||||||||
| \returns | ||||||||||
| \tcode{il.begin()}. | ||||||||||
| \end{itemdescr} | ||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I liked the style in the paper better,
which is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually break after the template-head, and then maybe also break later in the declaration. But I think the
<iterator>synopsis is unusual (unique even?) in doing:template<class C> constexpr autoThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. I think it would be move conventional to do:
and if that doesn't fit, then something like: