Skip to content

Commit 72039ac

Browse files
authored
Merge 2025-11 LWG Motion 3
P3016R6 Resolve inconsistencies in begin/end for valarray and braced initializer lists
2 parents 721d01c + 879d7ff commit 72039ac

File tree

7 files changed

+130
-112
lines changed

7 files changed

+130
-112
lines changed

source/containers.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20555,7 +20555,7 @@
2055520555

2055620556
\pnum
2055720557
\effects
20558-
Initializes \exposid{data_} with \tcode{il.begin()} and
20558+
Initializes \exposid{data_} with \tcode{il.data()} and
2055920559
\exposid{size_} with \tcode{il.size()}.
2056020560
\end{itemdescr}
2056120561

source/iterators.tex

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
\begin{codeblock}
3434
#include <compare> // see \ref{compare.syn}
3535
#include <concepts> // see \ref{concepts.syn}
36+
#include <initializer_list> // see \ref{initializer.list.syn}
3637

3738
namespace std {
3839
template<class T> using @\exposid{with-reference}@ = T&; // \expos
@@ -464,53 +465,64 @@
464465
class ostreambuf_iterator;
465466

466467
// \ref{iterator.range}, range access
467-
template<class C> constexpr auto begin(C& c) -> decltype(c.begin()); // freestanding
468-
template<class C> constexpr auto begin(const C& c) -> decltype(c.begin()); // freestanding
469-
template<class C> constexpr auto end(C& c) -> decltype(c.end()); // freestanding
470-
template<class C> constexpr auto end(const C& c) -> decltype(c.end()); // freestanding
468+
template<class C> constexpr auto
469+
begin(C& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()); // freestanding
470+
template<class C> constexpr auto
471+
begin(const C& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()); // freestanding
472+
template<class C> constexpr auto
473+
end(C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); // freestanding
474+
template<class C> constexpr auto
475+
end(const C& c) noexcept(noexcept(c.end())) -> decltype(c.end()); // freestanding
471476
template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; // freestanding
472477
template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; // freestanding
473-
template<class C> constexpr auto cbegin(const C& c) // freestanding
474-
noexcept(noexcept(std::begin(c))) -> decltype(std::begin(c));
475-
template<class C> constexpr auto cend(const C& c) // freestanding
476-
noexcept(noexcept(std::end(c))) -> decltype(std::end(c));
477-
template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin()); // freestanding
478-
template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin()); // freestanding
479-
template<class C> constexpr auto rend(C& c) -> decltype(c.rend()); // freestanding
480-
template<class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // freestanding
481-
template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]) // freestanding
482-
template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]); // freestanding
478+
template<class C> constexpr auto
479+
cbegin(const C& c) noexcept(noexcept(std::begin(c)))
480+
-> decltype(std::begin(c)); // freestanding
481+
template<class C> constexpr auto
482+
cend(const C& c) noexcept(noexcept(std::end(c))) -> decltype(std::end(c)); // freestanding
483+
template<class C> constexpr auto
484+
rbegin(C& c) noexcept(noexcept(c.rbegin())) -> decltype(c.rbegin()); // freestanding
485+
template<class C> constexpr auto
486+
rbegin(const C& c) noexcept(noexcept(c.rbegin())) -> decltype(c.rbegin()); // freestanding
487+
template<class C> constexpr auto
488+
rend(C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend()); // freestanding
489+
template<class C> constexpr auto
490+
rend(const C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend()); // freestanding
491+
template<class T, size_t N> constexpr reverse_iterator<T*>
492+
rbegin(T (&array)[N]) noexcept; // freestanding
493+
template<class T, size_t N> constexpr reverse_iterator<T*>
494+
rend(T (&array)[N]) noexcept; // freestanding
483495
template<class E> constexpr reverse_iterator<const E*>
484-
rbegin(initializer_list<E> il); // freestanding
496+
rbegin(initializer_list<E> il) noexcept; // freestanding
485497
template<class E> constexpr reverse_iterator<const E*>
486-
rend(initializer_list<E> il); // freestanding
498+
rend(initializer_list<E> il) noexcept; // freestanding
487499
template<class C> constexpr auto
488-
crbegin(const C& c) -> decltype(std::rbegin(c)); // freestanding
500+
crbegin(const C& c) noexcept(noexcept(std::rbegin(c)))
501+
-> decltype(std::rbegin(c)); // freestanding
489502
template<class C> constexpr auto
490-
crend(const C& c) -> decltype(std::rend(c)); // freestanding
503+
crend(const C& c) noexcept(noexcept(std::rend(c))) -> decltype(std::rend(c)); // freestanding
491504

492505
template<class C> constexpr auto
493-
size(const C& c) -> decltype(c.size()); // freestanding
506+
size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size()); // freestanding
494507
template<class T, size_t N> constexpr size_t
495508
size(const T (&array)[N]) noexcept; // freestanding
496509

497510
template<class C> constexpr auto
498-
ssize(const C& c)
511+
ssize(const C& c) noexcept(noexcept(c.size()))
499512
-> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // freestanding
500513
template<class T, ptrdiff_t N> constexpr ptrdiff_t
501514
ssize(const T (&array)[N]) noexcept; // freestanding
502515

503516
template<class C> constexpr auto
504-
empty(const C& c) -> decltype(c.empty()); // freestanding
517+
empty(const C& c) noexcept(noexcept(c.empty())) -> decltype(c.empty()); // freestanding
505518
template<class T, size_t N> constexpr bool
506519
empty(const T (&array)[N]) noexcept; // freestanding
507-
template<class E> constexpr bool
508-
empty(initializer_list<E> il) noexcept; // freestanding
509520

510-
template<class C> constexpr auto data(C& c) -> decltype(c.data()); // freestanding
511-
template<class C> constexpr auto data(const C& c) -> decltype(c.data()); // freestanding
521+
template<class C> constexpr auto
522+
data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data()); // freestanding
523+
template<class C> constexpr auto
524+
data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data()); // freestanding
512525
template<class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // freestanding
513-
template<class E> constexpr const E* data(initializer_list<E> il) noexcept; // freestanding
514526
}
515527
\end{codeblock}
516528

@@ -7251,19 +7263,24 @@
72517263
\libheaderrefx{inplace_vector}{inplace.vector.syn},
72527264
\libheaderref{list},
72537265
\libheaderrefx{map}{associative.map.syn},
7266+
\libheaderref{optional},
72547267
\libheaderrefx{regex}{re.syn},
72557268
\libheaderrefx{set}{associative.set.syn},
72567269
\libheaderref{span},
7270+
\libheaderref{stacktrace},
72577271
\libheaderref{string},
72587272
\libheaderrefx{string_view}{string.view.synop},
72597273
\libheaderrefx{unordered_map}{unord.map.syn},
7260-
\libheaderrefx{unordered_set}{unord.set.syn}, and
7274+
\libheaderrefxx{unordered_set}{unorder\-ed_set}{unord.set.syn}
7275+
\libheaderref{valarray}, and
72617276
\libheaderref{vector}.
72627277

72637278
\indexlibrary{\idxcode{begin(C\&)}}%
72647279
\begin{itemdecl}
7265-
template<class C> constexpr auto begin(C& c) -> decltype(c.begin());
7266-
template<class C> constexpr auto begin(const C& c) -> decltype(c.begin());
7280+
template<class C> constexpr auto begin(C& c) noexcept(noexcept(c.begin()))
7281+
-> decltype(c.begin());
7282+
template<class C> constexpr auto begin(const C& c) noexcept(noexcept(c.begin()))
7283+
-> decltype(c.begin());
72677284
\end{itemdecl}
72687285

72697286
\begin{itemdescr}
@@ -7274,8 +7291,8 @@
72747291

72757292
\indexlibrary{\idxcode{end(C\&)}}%
72767293
\begin{itemdecl}
7277-
template<class C> constexpr auto end(C& c) -> decltype(c.end());
7278-
template<class C> constexpr auto end(const C& c) -> decltype(c.end());
7294+
template<class C> constexpr auto end(C& c) noexcept(noexcept(c.end())) -> decltype(c.end());
7295+
template<class C> constexpr auto end(const C& c) noexcept(noexcept(c.end())) -> decltype(c.end());
72797296
\end{itemdecl}
72807297

72817298
\begin{itemdescr}
@@ -7330,8 +7347,10 @@
73307347

73317348
\indexlibrary{\idxcode{rbegin(C\&)}}%
73327349
\begin{itemdecl}
7333-
template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin());
7334-
template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin());
7350+
template<class C> constexpr auto rbegin(C& c) noexcept(noexcept(c.rbegin()))
7351+
-> decltype(c.rbegin());
7352+
template<class C> constexpr auto rbegin(const C& c) noexcept(noexcept(c.rbegin()))
7353+
-> decltype(c.rbegin());
73357354
\end{itemdecl}
73367355
\begin{itemdescr}
73377356
\pnum
@@ -7341,8 +7360,9 @@
73417360

73427361
\indexlibrary{\idxcode{rend(C\&)}}%
73437362
\begin{itemdecl}
7344-
template<class C> constexpr auto rend(C& c) -> decltype(c.rend());
7345-
template<class C> constexpr auto rend(const C& c) -> decltype(c.rend());
7363+
template<class C> constexpr auto rend(C& c) noexcept(noexcept(c.rend())) -> decltype(c.rend());
7364+
template<class C> constexpr auto rend(const C& c) noexcept(noexcept(c.rend()))
7365+
-> decltype(c.rend());
73467366
\end{itemdecl}
73477367
\begin{itemdescr}
73487368
\pnum
@@ -7352,7 +7372,7 @@
73527372

73537373
\indexlibrary{\idxcode{rbegin(T (\&array)[N])}}%
73547374
\begin{itemdecl}
7355-
template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]);
7375+
template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]) noexcept;
73567376
\end{itemdecl}
73577377
\begin{itemdescr}
73587378
\pnum
@@ -7362,7 +7382,7 @@
73627382

73637383
\indexlibrary{\idxcode{rend(T (\&array)[N])}}%
73647384
\begin{itemdecl}
7365-
template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]);
7385+
template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]) noexcept;
73667386
\end{itemdecl}
73677387
\begin{itemdescr}
73687388
\pnum
@@ -7372,7 +7392,7 @@
73727392

73737393
\indexlibrary{\idxcode{rbegin(initializer_list<E>)}}%
73747394
\begin{itemdecl}
7375-
template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il);
7395+
template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il) noexcept;
73767396
\end{itemdecl}
73777397
\begin{itemdescr}
73787398
\pnum
@@ -7382,7 +7402,7 @@
73827402

73837403
\indexlibrary{\idxcode{rend(initializer_list<E>)}}%
73847404
\begin{itemdecl}
7385-
template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il);
7405+
template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il) noexcept;
73867406
\end{itemdecl}
73877407
\begin{itemdescr}
73887408
\pnum
@@ -7392,7 +7412,8 @@
73927412

73937413
\indexlibrary{\idxcode{crbegin(const C\& c)}}%
73947414
\begin{itemdecl}
7395-
template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));
7415+
template<class C> constexpr auto crbegin(const C& c) noexcept(noexcept(std::rbegin(c)))
7416+
-> decltype(std::rbegin(c));
73967417
\end{itemdecl}
73977418
\begin{itemdescr}
73987419
\pnum
@@ -7402,7 +7423,8 @@
74027423

74037424
\indexlibrary{\idxcode{crend(const C\& c)}}%
74047425
\begin{itemdecl}
7405-
template<class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));
7426+
template<class C> constexpr auto crend(const C& c) noexcept(noexcept(c.crend()))
7427+
-> decltype(std::rend(c));
74067428
\end{itemdecl}
74077429
\begin{itemdescr}
74087430
\pnum
@@ -7412,7 +7434,8 @@
74127434

74137435
\indexlibrary{\idxcode{size(C\& c)}}%
74147436
\begin{itemdecl}
7415-
template<class C> constexpr auto size(const C& c) -> decltype(c.size());
7437+
template<class C> constexpr auto size(const C& c) noexcept(noexcept(c.size()))
7438+
-> decltype(c.size());
74167439
\end{itemdecl}
74177440
\begin{itemdescr}
74187441
\pnum
@@ -7432,7 +7455,7 @@
74327455

74337456
\indexlibrary{\idxcode{ssize(C\& c)}}%
74347457
\begin{itemdecl}
7435-
template<class C> constexpr auto ssize(const C& c)
7458+
template<class C> constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
74367459
-> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;
74377460
\end{itemdecl}
74387461
\begin{itemdescr}
@@ -7456,7 +7479,8 @@
74567479

74577480
\indexlibrary{\idxcode{empty(C\& c)}}%
74587481
\begin{itemdecl}
7459-
template<class C> constexpr auto empty(const C& c) -> decltype(c.empty());
7482+
template<class C> constexpr auto empty(const C& c) noexcept(noexcept(c.empty()))
7483+
-> decltype(c.empty());
74607484
\end{itemdecl}
74617485
\begin{itemdescr}
74627486
\pnum
@@ -7474,20 +7498,11 @@
74747498
\tcode{false}.
74757499
\end{itemdescr}
74767500

7477-
\indexlibrary{\idxcode{empty(initializer_list<E>)}}%
7478-
\begin{itemdecl}
7479-
template<class E> constexpr bool empty(initializer_list<E> il) noexcept;
7480-
\end{itemdecl}
7481-
\begin{itemdescr}
7482-
\pnum
7483-
\returns
7484-
\tcode{il.size() == 0}.
7485-
\end{itemdescr}
7486-
74877501
\indexlibrary{\idxcode{data(C\& c)}}%
74887502
\begin{itemdecl}
7489-
template<class C> constexpr auto data(C& c) -> decltype(c.data());
7490-
template<class C> constexpr auto data(const C& c) -> decltype(c.data());
7503+
template<class C> constexpr auto data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data());
7504+
template<class C> constexpr auto data(const C& c) noexcept(noexcept(c.data()))
7505+
-> decltype(c.data());
74917506
\end{itemdecl}
74927507
\begin{itemdescr}
74937508
\pnum
@@ -7504,13 +7519,3 @@
75047519
\returns
75057520
\tcode{array}.
75067521
\end{itemdescr}
7507-
7508-
\indexlibrary{\idxcode{data(initializer_list<E>)}}%
7509-
\begin{itemdecl}
7510-
template<class E> constexpr const E* data(initializer_list<E> il) noexcept;
7511-
\end{itemdecl}
7512-
\begin{itemdescr}
7513-
\pnum
7514-
\returns
7515-
\tcode{il.begin()}.
7516-
\end{itemdescr}

0 commit comments

Comments
 (0)