Skip to content

Commit be2a5d2

Browse files
authored
Merge 2023-02 LWG Motion 2
P2789R0 C++ Standard Library Issues to be moved in Issaquah, Feb. 2023
2 parents a6550ab + a47bdd7 commit be2a5d2

15 files changed

+345
-121
lines changed

source/algorithms.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8398,6 +8398,8 @@
83988398
The range \range{first}{last - 1}
83998399
is a valid heap with respect to \tcode{comp} and \tcode{proj}.
84008400
For the overloads in namespace \tcode{std},
8401+
\tcode{RandomAccessIterator} meets
8402+
the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and
84018403
the type of \tcode{*first} meets
84028404
the \oldconcept{MoveConstructible} requirements (\tref{cpp17.moveconstructible}) and
84038405
the \oldconcept{MoveAssignable} requirements (\tref{cpp17.moveassignable}).
@@ -8505,8 +8507,10 @@
85058507
\pnum
85068508
\expects
85078509
For the overloads in namespace \tcode{std},
8510+
\tcode{RandomAccessIterator} meets
8511+
the \oldconcept{ValueSwap\-pable} requirements\iref{swappable.requirements} and
85088512
the type of \tcode{*first} meets
8509-
the \oldconcept{Move\-Constructible} (\tref{cpp17.moveconstructible}) and
8513+
the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and
85108514
\oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements.
85118515

85128516
\pnum

source/compatibility.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,24 @@
231231
std::format("{}", t.bit); // ill-formed, previously returned \tcode{"0"}
232232
\end{codeblock}
233233

234+
\diffref{format.string.std}
235+
\change
236+
Restrict types of formatting arguments
237+
used as \fmtgrammarterm{width} or \fmtgrammarterm{precision} in
238+
a \fmtgrammarterm{std-format-spec}.
239+
\rationale
240+
Disallow types that do not have useful or portable semantics as
241+
a formatting width or precision.
242+
\effect
243+
Valid \CppXX{} code that passes a boolean or character type as
244+
\fmtgrammarterm{arg-id} becomes invalid.
245+
For example:
246+
\begin{codeblock}
247+
std::format("{:*^{}}", "", true); // ill-formed, previously returned \tcode{"*"}
248+
std::format("{:*^{}}", "", '1'); // ill-formed, previously returned an
249+
// implementation-defined number of \tcode{'*'} characters
250+
\end{codeblock}
251+
234252
\rSec2[diff.cpp20.strings]{\ref{strings}: strings library}
235253

236254
\diffref{string.classes}

source/containers.tex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,12 @@
20082008
\expects
20092009
\tcode{T} is \oldconcept{EmplaceConstructible} into \tcode{X}
20102010
from \tcode{*ranges::begin(rg)}.
2011+
For \tcode{deque},
2012+
\tcode{T} is also \oldconcept{MoveInsertable} into \tcode{X}, and
2013+
\tcode{T} meets the
2014+
\oldconcept{MoveConstructible},
2015+
\oldconcept{MoveAssignable}, and
2016+
\oldconcept{Swappable}\iref{swappable.requirements} requirements.
20112017

20122018
\pnum
20132019
\effects

source/iostreams.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12510,7 +12510,7 @@
1251012510
~basic_osyncstream();
1251112511

1251212512
// assignment
12513-
basic_osyncstream& operator=(basic_osyncstream&&) noexcept;
12513+
basic_osyncstream& operator=(basic_osyncstream&&);
1251412514

1251512515
// \ref{syncstream.osyncstream.members}, member functions
1251612516
void emit();
@@ -18515,15 +18515,15 @@
1851518515
namespace std {
1851618516
using imaxdiv_t = @\seebelow@;
1851718517

18518-
intmax_t imaxabs(intmax_t j);
18519-
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
18518+
constexpr intmax_t imaxabs(intmax_t j);
18519+
constexpr imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
1852018520
intmax_t strtoimax(const char* nptr, char** endptr, int base);
1852118521
uintmax_t strtoumax(const char* nptr, char** endptr, int base);
1852218522
intmax_t wcstoimax(const wchar_t* nptr, wchar_t** endptr, int base);
1852318523
uintmax_t wcstoumax(const wchar_t* nptr, wchar_t** endptr, int base);
1852418524

18525-
intmax_t abs(intmax_t); // optional, see below
18526-
imaxdiv_t div(intmax_t, intmax_t); // optional, see below
18525+
constexpr intmax_t abs(intmax_t); // optional, see below
18526+
constexpr imaxdiv_t div(intmax_t, intmax_t); // optional, see below
1852718527
}
1852818528

1852918529
#define PRId@\placeholdernc{N}@ @\seebelow@
@@ -18595,12 +18595,12 @@
1859518595
if and only if the type \tcode{intmax_t} designates an extended integer
1859618596
type\iref{basic.fundamental}, the following function signatures are added:
1859718597
\begin{codeblock}
18598-
intmax_t abs(intmax_t);
18599-
imaxdiv_t div(intmax_t, intmax_t);
18598+
constexpr intmax_t abs(intmax_t);
18599+
constexpr imaxdiv_t div(intmax_t, intmax_t);
1860018600
\end{codeblock}
1860118601
which shall have the same semantics as the function signatures
18602-
\tcode{intmax_t imaxabs(intmax_t)} and
18603-
\tcode{imaxdiv_t imaxdiv(intmax_t, intmax_t)}, respectively.
18602+
\tcode{constexpr intmax_t imaxabs(intmax_t)} and
18603+
\tcode{constexpr imaxdiv_t imaxdiv(intmax_t, intmax_t)}, respectively.
1860418604
\end{itemize}
1860518605

1860618606
\xrefc{7.8}

source/iterators.tex

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@
243243
S bound);
244244

245245
// \ref{range.iter.op.distance}, \tcode{ranges::distance}
246-
template<@\libconcept{input_or_output_iterator}@ I, @\libconcept{sentinel_for}@<I> S>
246+
template<class I, @\libconcept{sentinel_for}@<I> S>
247247
requires (!@\libconcept{sized_sentinel_for}@<S, I>)
248248
constexpr iter_difference_t<I> distance(I first, S last); // freestanding
249-
template<@\libconcept{input_or_output_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S>
250-
constexpr iter_difference_t<I> distance(const I& first, const S& last); // freestanding
249+
template<class I, @\libconcept{sized_sentinel_for}@<decay_t<I>> S>
250+
constexpr iter_difference_t<decay_t<I>> distance(I&& first, S last); // freestanding
251251
template<@\libconcept{range}@ R>
252252
constexpr range_difference_t<R> distance(R&& r); // freestanding
253253

@@ -3028,7 +3028,7 @@
30283028
\rSec3[range.iter.op.distance]{\tcode{ranges::distance}}
30293029
\indexlibraryglobal{distance}%
30303030
\begin{itemdecl}
3031-
template<@\libconcept{input_or_output_iterator}@ I, @\libconcept{sentinel_for}@<I> S>
3031+
template<class I, @\libconcept{sentinel_for}@<I> S>
30323032
requires (!@\libconcept{sized_sentinel_for}@<S, I>)
30333033
constexpr iter_difference_t<I> ranges::distance(I first, S last);
30343034
\end{itemdecl}
@@ -3046,14 +3046,14 @@
30463046

30473047
\indexlibraryglobal{distance}%
30483048
\begin{itemdecl}
3049-
template<@\libconcept{input_or_output_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S>
3050-
constexpr iter_difference_t<I> ranges::distance(const I& first, const S& last);
3049+
template<class I, @\libconcept{sized_sentinel_for}@<decay_t<I>> S>
3050+
constexpr iter_difference_t<decay_t<I>> ranges::distance(I&& first, S last);
30513051
\end{itemdecl}
30523052

30533053
\begin{itemdescr}
30543054
\pnum
30553055
\effects
3056-
Equivalent to: \tcode{return last - first;}
3056+
Equivalent to: \tcode{return last - static_cast<const decay_t<I>\&>(first);}
30573057
\end{itemdescr}
30583058

30593059
\indexlibraryglobal{distance}%
@@ -4236,7 +4236,7 @@
42364236
constexpr Iterator base() &&;
42374237

42384238
constexpr @\exposid{reference}@ operator*() const;
4239-
constexpr const value_type* operator->() const
4239+
constexpr const auto* operator->() const
42404240
requires is_lvalue_reference_v<iter_reference_t<Iterator>> &&
42414241
@\libconcept{same_as}@<remove_cvref_t<iter_reference_t<Iterator>>, value_type>;
42424242

@@ -4256,34 +4256,35 @@
42564256
requires @\libconcept{random_access_iterator}@<Iterator>;
42574257

42584258
template<@\libconcept{sentinel_for}@<Iterator> S>
4259-
friend constexpr bool operator==(const basic_const_iterator& x, const S& s);
4259+
constexpr bool operator==(const S& s) const;
42604260

4261-
friend constexpr bool operator<(const basic_const_iterator& x, const basic_const_iterator& y)
4261+
constexpr bool operator<(const basic_const_iterator& y) const
42624262
requires @\libconcept{random_access_iterator}@<Iterator>;
4263-
friend constexpr bool operator>(const basic_const_iterator& x, const basic_const_iterator& y)
4263+
constexpr bool operator>(const basic_const_iterator& y) const
42644264
requires @\libconcept{random_access_iterator}@<Iterator>;
4265-
friend constexpr bool operator<=(const basic_const_iterator& x,
4266-
const basic_const_iterator& y)
4265+
constexpr bool operator<=(const basic_const_iterator& y) const
42674266
requires @\libconcept{random_access_iterator}@<Iterator>;
4268-
friend constexpr bool operator>=(const basic_const_iterator& x,
4269-
const basic_const_iterator& y)
4267+
constexpr bool operator>=(const basic_const_iterator& y) const
42704268
requires @\libconcept{random_access_iterator}@<Iterator>;
4271-
friend constexpr auto operator<=>(const basic_const_iterator& x,
4272-
const basic_const_iterator& y)
4269+
constexpr auto operator<=>(const basic_const_iterator& y) const
42734270
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{three_way_comparable}@<Iterator>;
42744271

42754272
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4276-
friend constexpr bool operator<(const basic_const_iterator& x, const I& y)
4273+
constexpr bool operator<(const I& y) const
42774274
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
42784275
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4279-
friend constexpr bool operator>(const basic_const_iterator& x, const I& y)
4276+
constexpr bool operator>(const I& y) const
42804277
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
42814278
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4282-
friend constexpr bool operator<=(const basic_const_iterator& x, const I& y)
4279+
constexpr bool operator<=(const I& y) const
42834280
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
42844281
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4285-
friend constexpr bool operator>=(const basic_const_iterator& x, const I& y)
4282+
constexpr bool operator>=(const I& y) const
42864283
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
4284+
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4285+
constexpr auto operator<=>(const I& y) const
4286+
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I> &&
4287+
@\libconcept{three_way_comparable_with}@<Iterator, I>;
42874288
template<@\exposconcept{not-a-const-iterator}@ I>
42884289
friend constexpr bool operator<(const I& x, const basic_const_iterator& y)
42894290
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
@@ -4296,10 +4297,6 @@
42964297
template<@\exposconcept{not-a-const-iterator}@ I>
42974298
friend constexpr bool operator>=(const I& x, const basic_const_iterator& y)
42984299
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
4299-
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4300-
friend constexpr auto operator<=>(const basic_const_iterator& x, const I& y)
4301-
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I> &&
4302-
@\libconcept{three_way_comparable_with}@<Iterator, I>;
43034300

43044301
friend constexpr basic_const_iterator operator+(const basic_const_iterator& i,
43054302
difference_type n)
@@ -4311,9 +4308,9 @@
43114308
difference_type n)
43124309
requires @\libconcept{random_access_iterator}@<Iterator>;
43134310
template<@\libconcept{sized_sentinel_for}@<Iterator> S>
4314-
friend constexpr difference_type operator-(const basic_const_iterator& x, const S& y);
4315-
template<@\libconcept{sized_sentinel_for}@<Iterator> S>
4316-
requires @\exposconcept{different-from}@<S, basic_const_iterator>
4311+
constexpr difference_type operator-(const S& y) const;
4312+
template<@\exposconcept{not-a-const-iterator}@ S>
4313+
requires @\libconcept{sized_sentinel_for}@<S, Iterator>
43174314
friend constexpr difference_type operator-(const S& x, const basic_const_iterator& y);
43184315
};
43194316
}
@@ -4427,7 +4424,7 @@
44274424

44284425
\indexlibrarymember{operator->}{basic_const_iterator}%
44294426
\begin{itemdecl}
4430-
constexpr const value_type* operator->() const
4427+
constexpr const auto* operator->() const
44314428
requires is_lvalue_reference_v<iter_reference_t<Iterator>> &&
44324429
@\libconcept{same_as}@<remove_cvref_t<iter_reference_t<Iterator>>, value_type>;
44334430
\end{itemdecl}
@@ -4549,13 +4546,13 @@
45494546
\indexlibrarymember{operator==}{basic_const_iterator}%
45504547
\begin{itemdecl}
45514548
template<@\libconcept{sentinel_for}@<Iterator> S>
4552-
friend constexpr bool operator==(const basic_const_iterator& x, const S& s);
4549+
constexpr bool operator==(const S& s) const;
45534550
\end{itemdecl}
45544551

45554552
\begin{itemdescr}
45564553
\pnum
45574554
\effects
4558-
Equivalent to: \tcode{return x.\exposid{current_} == s;}
4555+
Equivalent to: \tcode{return \exposid{current_} == s;}
45594556
\end{itemdescr}
45604557

45614558
\indexlibrarymember{operator<}{basic_const_iterator}%
@@ -4564,15 +4561,15 @@
45644561
\indexlibrarymember{operator>=}{basic_const_iterator}%
45654562
\indexlibrarymember{operator<=>}{basic_const_iterator}%
45664563
\begin{itemdecl}
4567-
friend constexpr bool operator<(const basic_const_iterator& x, const basic_const_iterator& y)
4564+
constexpr bool operator<(const basic_const_iterator& y) const
45684565
requires @\libconcept{random_access_iterator}@<Iterator>;
4569-
friend constexpr bool operator>(const basic_const_iterator& x, const basic_const_iterator& y)
4566+
constexpr bool operator>(const basic_const_iterator& y) const
45704567
requires @\libconcept{random_access_iterator}@<Iterator>;
4571-
friend constexpr bool operator<=(const basic_const_iterator& x, const basic_const_iterator& y)
4568+
constexpr bool operator<=(const basic_const_iterator& y) const
45724569
requires @\libconcept{random_access_iterator}@<Iterator>;
4573-
friend constexpr bool operator>=(const basic_const_iterator& x, const basic_const_iterator& y)
4570+
constexpr bool operator>=(const basic_const_iterator& y) const
45744571
requires @\libconcept{random_access_iterator}@<Iterator>;
4575-
friend constexpr auto operator<=>(const basic_const_iterator& x, const basic_const_iterator& y)
4572+
constexpr auto operator<=>(const basic_const_iterator& y) const
45764573
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{three_way_comparable}@<Iterator>;
45774574
\end{itemdecl}
45784575

@@ -4583,7 +4580,7 @@
45834580
\pnum
45844581
\effects
45854582
Equivalent to:
4586-
\tcode{return x.\exposid{current_} \placeholder{op} \exposid{y.current_};}
4583+
\tcode{return \exposid{current_} \placeholder{op} \exposid{y.current_};}
45874584
\end{itemdescr}
45884585

45894586
\indexlibrarymember{operator<}{basic_const_iterator}%
@@ -4593,19 +4590,19 @@
45934590
\indexlibrarymember{operator<=>}{basic_const_iterator}%
45944591
\begin{itemdecl}
45954592
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4596-
friend constexpr bool operator<(const basic_const_iterator& x, const I& y)
4593+
constexpr bool operator<(const I& y) const
45974594
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
45984595
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4599-
friend constexpr bool operator>(const basic_const_iterator& x, const I& y)
4596+
constexpr bool operator>(const I& y) const
46004597
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
46014598
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4602-
friend constexpr bool operator<=(const basic_const_iterator& x, const I& y)
4599+
constexpr bool operator<=(const I& y) const
46034600
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
46044601
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4605-
friend constexpr bool operator>=(const basic_const_iterator& x, const I& y)
4602+
constexpr bool operator>=(const I& y) const
46064603
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I>;
46074604
template<@\exposconcept{different-from}@<basic_const_iterator> I>
4608-
friend constexpr auto operator<=>(const basic_const_iterator& x, const I& y)
4605+
constexpr auto operator<=>(const I& y) const
46094606
requires @\libconcept{random_access_iterator}@<Iterator> && @\libconcept{totally_ordered_with}@<Iterator, I> &&
46104607
@\libconcept{three_way_comparable_with}@<Iterator, I>;
46114608
\end{itemdecl}
@@ -4615,8 +4612,8 @@
46154612
Let \tcode{\placeholder{op}} be the operator.
46164613

46174614
\pnum
4618-
\returns
4619-
Equivalent to: \tcode{return x.\exposid{current_} \placeholder{op} y;}
4615+
\effects
4616+
Equivalent to: \tcode{return \exposid{current_} \placeholder{op} y;}
46204617
\end{itemdescr}
46214618

46224619
\indexlibrarymember{operator<}{basic_const_iterator}%
@@ -4675,19 +4672,19 @@
46754672
\indexlibrarymember{operator-}{basic_const_iterator}%
46764673
\begin{itemdecl}
46774674
template<@\libconcept{sized_sentinel_for}@<Iterator> S>
4678-
friend constexpr difference_type operator-(const basic_const_iterator& x, const S& y);
4675+
constexpr difference_type operator-(const S& y) const;
46794676
\end{itemdecl}
46804677

46814678
\begin{itemdescr}
46824679
\pnum
46834680
\effects
4684-
Equivalent to: \tcode{return x.\exposid{current_} - y;}
4681+
Equivalent to: \tcode{return \exposid{current_} - y;}
46854682
\end{itemdescr}
46864683

46874684
\indexlibrarymember{operator-}{basic_const_iterator}%
46884685
\begin{itemdecl}
4689-
template<@\libconcept{sized_sentinel_for}@<Iterator> S>
4690-
requires @\exposconcept{different-from}@<S, basic_const_iterator>
4686+
template<@\exposconcept{not-a-const-iterator}@ S>
4687+
requires @\libconcept{sized_sentinel_for}@<S, Iterator>
46914688
friend constexpr difference_type operator-(const S& x, const basic_const_iterator& y);
46924689
\end{itemdecl}
46934690

0 commit comments

Comments
 (0)