Skip to content

Commit b696e24

Browse files
authored
Merge 2022-02 LWG Motion 1
P2531R0 C++ Standard Library Issues This excludes LWG3616, which was already applied editorially as 8753efa.
2 parents 5be92a9 + 3452bc7 commit b696e24

File tree

9 files changed

+162
-76
lines changed

9 files changed

+162
-76
lines changed

source/atomics.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,7 @@
28012801
bool is_lock_free() const noexcept;
28022802

28032803
constexpr atomic() noexcept;
2804+
constexpr atomic(nullptr_t) noexcept : atomic() { }
28042805
atomic(shared_ptr<T> desired) noexcept;
28052806
atomic(const atomic&) = delete;
28062807
void operator=(const atomic&) = delete;

source/containers.tex

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7156,18 +7156,22 @@
71567156
\end{itemdecl}
71577157

71587158
\begin{itemdescr}
7159+
\pnum
7160+
Let \tcode{comp} be \tcode{less<>{}} for the first two overloads.
7161+
71597162
\pnum
71607163
\expects
7161-
\tcode{*this} and \tcode{x} are both sorted with respect to
7162-
the comparator \tcode{operator<} (for the first two overloads) or
7163-
\tcode{comp} (for the last two overloads), and
7164+
\tcode{*this} and \tcode{x} are both sorted
7165+
with respect to the comparator \tcode{comp}, and
71647166
\tcode{get_allocator() == x.get_allocator()} is \tcode{true}.
71657167

71667168
\pnum
71677169
\effects
7168-
Merges the two sorted ranges \tcode{[begin(), end())} and
7169-
\tcode{[x.begin(), x.end())}. \tcode{x} is empty after the merge. If an
7170-
exception is thrown other than by a comparison there are no effects.
7170+
If \tcode{addressof(x) == this}, there are no effects.
7171+
Otherwise, merges
7172+
the two sorted ranges \range{begin()}{end()} and \range{x.begin()}{x.end()}.
7173+
The result is a range
7174+
that is sorted with respect to the comparator \tcode{comp}.
71717175
Pointers and references to the moved elements of \tcode{x} now refer to those same elements
71727176
but as members of \tcode{*this}. Iterators referring to the moved elements will continue to
71737177
refer to their elements, but they now behave as iterators into \tcode{*this}, not into
@@ -7176,11 +7180,15 @@
71767180
\pnum
71777181
\complexity
71787182
At most \tcode{distance(begin(),
7179-
end()) + distance(x.begin(), x.end()) - 1} comparisons.
7183+
end()) + distance(x.begin(), x.end()) - 1} comparisons
7184+
if \tcode{addressof(x) != this}; otherwise, no comparisons are performed.
71807185

71817186
\pnum
71827187
\remarks
71837188
Stable\iref{algorithm.stable}.
7189+
If \tcode{addressof(x) != this}, \tcode{x} is empty after the merge.
7190+
No elements are copied by this operation.
7191+
If an exception is thrown other than by a comparison, there are no effects.
71847192
\end{itemdescr}
71857193

71867194
\indexlibrarymember{sort}{forward_list}%
@@ -7857,40 +7865,39 @@
78577865
\end{itemdecl}
78587866

78597867
\begin{itemdescr}
7868+
\pnum
7869+
Let \tcode{comp} be \tcode{less<>{}} for the first two overloads.
7870+
78607871
\pnum
78617872
\expects
7862-
Both the list and the argument list
7863-
shall be sorted with respect to
7864-
the comparator \tcode{operator<} (for the first two overloads) or
7865-
\tcode{comp} (for the last two overloads), and
7873+
\tcode{*this} and \tcode{x} are both sorted
7874+
with respect to the comparator \tcode{comp}, and
78667875
\tcode{get_allocator() == x.get_allocator()} is \tcode{true}.
78677876

78687877
\pnum
78697878
\effects
7870-
If \tcode{addressof(x) == this}, does nothing; otherwise, merges the two sorted ranges \tcode{[begin(),
7871-
end())} and \tcode{[x.\brk{}begin(), x.end())}. The result is a range in which the elements
7872-
will be sorted in non-decreasing order according to the ordering defined by \tcode{comp}; that
7873-
is, for every iterator \tcode{i}, in the range other than the first, the condition
7874-
\tcode{comp(*i, *(i - 1))} will be \tcode{false}.
7879+
If \tcode{addressof(x) == this}, there are no effects.
7880+
Otherwise, merges
7881+
the two sorted ranges \range{begin()}{end()} and \range{x.begin()}{x.end()}.
7882+
The result is a range
7883+
that is sorted with respect to the comparator \tcode{comp}.
78757884
Pointers and references to the moved elements of \tcode{x} now refer to those same elements
78767885
but as members of \tcode{*this}. Iterators referring to the moved elements will continue to
78777886
refer to their elements, but they now behave as iterators into \tcode{*this}, not into
78787887
\tcode{x}.
78797888

78807889
\pnum
78817890
\complexity
7882-
At most
7883-
\tcode{size() + x.size() - 1}
7884-
applications of \tcode{comp} if
7885-
\tcode{addressof(x) != this};
7886-
otherwise, no applications of \tcode{comp} are performed.
7887-
If an exception is thrown other than by a comparison there are no effects.
7891+
At most \tcode{size() + x.size() - 1} comparisons
7892+
if \tcode{addressof(x) != this};
7893+
otherwise, no comparisons are performed.
78887894

78897895
\pnum
78907896
\remarks
7891-
Stable\iref{algorithm.stable}. If \tcode{addressof(x) != this}, the range \tcode{[x.begin(), x.end())}
7892-
is empty after the merge.
7897+
Stable\iref{algorithm.stable}.
7898+
If \tcode{addressof(x) != this}, \tcode{x} is empty after the merge.
78937899
No elements are copied by this operation.
7900+
If an exception is thrown other than by a comparison there are no effects.
78947901
\end{itemdescr}
78957902

78967903
\indexlibrarymember{reverse}{list}%

source/diagnostics.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,13 @@
10461046
pointer to the string \tcode{"system"}. The object's \tcode{default_error_condition}
10471047
virtual function shall behave as follows:
10481048

1049-
If the argument \tcode{ev} corresponds to a POSIX \tcode{errno} value \tcode{posv}, the
1050-
function shall return \tcode{error_condition(posv, generic_category())}.
1051-
Otherwise, the function shall return \tcode{error_condition(ev,
1052-
system_category())}. What constitutes correspondence for any given operating
1053-
system is unspecified.
1049+
If the argument \tcode{ev} is equal to 0,
1050+
the function returns \tcode{error_condition(0, generic_category())}.
1051+
Otherwise,
1052+
if \tcode{ev} corresponds to a POSIX \tcode{errno} value \tcode{pxv},
1053+
the function returns \tcode{error_condition(pxv, generic_category())}.
1054+
Otherwise, the function returns \tcode{error_condition(ev, system_category())}.
1055+
What constitutes correspondence for any given operating system is unspecified.
10541056
\begin{note}
10551057
The number of potential system error codes is large
10561058
and unbounded, and some might not correspond to any POSIX \tcode{errno} value. Thus

source/iostreams.tex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12668,6 +12668,12 @@
1266812668
path weakly_canonical(const path& p, error_code& ec);
1266912669
}
1267012670

12671+
// \ref{fs.path.hash}, hash support
12672+
namespace std {
12673+
template<class T> struct hash;
12674+
template<> struct hash<filesystem::path>;
12675+
}
12676+
1267112677
namespace std::ranges {
1267212678
template<>
1267312679
inline constexpr bool enable_borrowed_range<filesystem::directory_iterator> = true;
@@ -14618,6 +14624,19 @@
1461814624
Equivalent to: \tcode{return path(lhs) /= rhs;}
1461914625
\end{itemdescr}
1462014626

14627+
\rSec3[fs.path.hash]{Hash support}
14628+
14629+
\begin{itemdecl}
14630+
template<> struct hash<filesystem::path>;
14631+
\end{itemdecl}
14632+
14633+
\begin{itemdescr}
14634+
\pnum
14635+
For an object \tcode{p} of type \tcode{filesystem::path},
14636+
\tcode{hash<filesystem::path>()(p)} evaluates to the same result as
14637+
\tcode{filesystem::hash_value(p)}.
14638+
\end{itemdescr}
14639+
1462114640
\rSec2[fs.class.filesystem.error]{Class \tcode{filesystem_error}}
1462214641

1462314642
\rSec3[fs.class.filesystem.error.general]{General}

source/iterators.tex

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,12 @@
19111911
The type \tcode{I} models \libconcept{contiguous_iterator} only if
19121912
\begin{itemize}
19131913
\item \tcode{to_address(a) == addressof(*a)},
1914-
\item \tcode{to_address(b) == to_address(a) + D(b - a)}, and
1915-
\item \tcode{to_address(c) == to_address(a) + D(c - a)}.
1914+
\item \tcode{to_address(b) == to_address(a) + D(b - a)},
1915+
\item \tcode{to_address(c) == to_address(a) + D(c - a)},
1916+
\item \tcode{ranges::iter_move(a)} has
1917+
the same type, value category, and effects as \tcode{std::move(*a)}, and
1918+
\item if \tcode{ranges::iter_swap(a, b)} is well-formed,
1919+
it has effects equivalent to \tcode{ranges::swap(*a, *b)}.
19161920
\end{itemize}
19171921

19181922
\rSec2[iterator.cpp17]{\Cpp{}17 iterator requirements}
@@ -2088,6 +2092,9 @@
20882092
The implementation of an algorithm on input iterators
20892093
should never attempt to pass through the same iterator twice;
20902094
such an algorithm should be a single pass algorithm.
2095+
2096+
\newpage
2097+
20912098
\begin{note}
20922099
For input iterators, \tcode{a == b} does not imply \tcode{++a == ++b}.
20932100
(Equality does not guarantee the substitution property or referential transparency.)
@@ -2107,8 +2114,6 @@
21072114
and the expressions in \tref{outputiterator}
21082115
are valid and have the indicated semantics.
21092116

2110-
\newpage
2111-
21122117
\begin{libreqtab4b}[floattable]
21132118
{\defnoldconcept{OutputIterator} requirements (in addition to \oldconcept{Iterator})}
21142119
{outputiterator}
@@ -4867,9 +4872,9 @@
48674872
otherwise it denotes \tcode{input_iterator_tag}.
48684873

48694874
\item
4875+
Let \tcode{a} denote an lvalue of type \tcode{const common_iterator<I, S>}.
48704876
If the expression \tcode{a.operator->()} is well-formed,
4871-
where \tcode{a} is an lvalue of type \tcode{const common_iterator<I, S>},
4872-
then \tcode{pointer} denotes the type of that expression.
4877+
then \tcode{pointer} denotes \tcode{decltype(a.operator->())}.
48734878
Otherwise, \tcode{pointer} denotes \keyword{void}.
48744879
\end{itemize}
48754880

@@ -5060,8 +5065,11 @@
50605065
Otherwise, if
50615066
\tcode{requires(I\& i) \{ \{ *i++ \} -> \exposconceptnc{can-reference}; \}}
50625067
is \tcode{true} or
5063-
\tcode{\libconceptx{constructible_\newline{}from}{constructible_from}<iter_value_t<I>, iter_reference_t<I>> \&\& \libconcept{move_constructible}<iter_value_t<I>>}
5064-
is \linebreak \tcode{false},
5068+
\begin{codeblock}
5069+
@\libconcept{indirectly_readable}@<I> && @\libconcept{constructible_from}@<iter_value_t<I>, iter_reference_t<I>> &&
5070+
@\libconcept{move_constructible}@<iter_value_t<I>>
5071+
\end{codeblock}
5072+
is \tcode{false},
50655073
equivalent to:
50665074
\begin{codeblock}
50675075
return get<I>(v_)++;
@@ -5273,7 +5281,7 @@
52735281
requires @\libconcept{contiguous_iterator}@<I>;
52745282

52755283
constexpr counted_iterator& operator++();
5276-
decltype(auto) operator++(int);
5284+
constexpr decltype(auto) operator++(int);
52775285
constexpr counted_iterator operator++(int)
52785286
requires @\libconcept{forward_iterator}@<I>;
52795287
constexpr counted_iterator& operator--()
@@ -5491,7 +5499,7 @@
54915499

54925500
\indexlibrarymember{operator++}{counted_iterator}%
54935501
\begin{itemdecl}
5494-
decltype(auto) operator++(int);
5502+
constexpr decltype(auto) operator++(int);
54955503
\end{itemdecl}
54965504

54975505
\begin{itemdescr}

source/ranges.tex

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,7 @@
24712471
\remarks
24722472
The expression in the \grammarterm{requires-clause} is equivalent to:
24732473
\begin{codeblock}
2474-
(@\libconcept{same_as}@<W, Bound> && @\exposconcept{advanceable}@<W>) || (@\libconcept{integral}@<W> && @\libconcept{integral}@<Bound>) ||
2474+
(@\libconcept{same_as}@<W, Bound> && @\exposconcept{advanceable}@<W>) || (@\exposid{is-integer-like}@<W> && @\exposid{is-integer-like}@<Bound>) ||
24752475
@\libconcept{sized_sentinel_for}@<Bound, W>
24762476
\end{codeblock}
24772477
\end{itemdescr}
@@ -4125,7 +4125,8 @@
41254125
constexpr const iterator_t<@\exposid{Base}@>& base() const & noexcept;
41264126
constexpr iterator_t<@\exposid{Base}@> base() &&;
41274127

4128-
constexpr decltype(auto) operator*() const {
4128+
constexpr decltype(auto) operator*() const
4129+
noexcept(noexcept(invoke(*@\exposid{parent_}@->@\exposid{fun_}@, *@\exposid{current_}@))) {
41294130
return invoke(*@\exposid{parent_}@->@\exposid{fun_}@, *@\exposid{current_}@);
41304131
}
41314132

@@ -4169,14 +4170,6 @@
41694170
requires @\libconcept{random_access_range}@<@\exposid{Base}@>;
41704171
friend constexpr difference_type operator-(const @\exposid{iterator}@& x, const @\exposid{iterator}@& y)
41714172
requires @\libconcept{sized_sentinel_for}@<iterator_t<@\exposid{Base}@>, iterator_t<@\exposid{Base}@>>;
4172-
4173-
friend constexpr decltype(auto) iter_move(const @\exposid{iterator}@& i)
4174-
noexcept(noexcept(invoke(*i.@\exposid{parent_}@->@\exposid{fun_}@, *i.@\exposid{current_}@))) {
4175-
if constexpr (is_lvalue_reference_v<decltype(*i)>)
4176-
return std::move(*i);
4177-
else
4178-
return *i;
4179-
}
41804173
};
41814174
}
41824175
\end{codeblock}

source/strings.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@
10881088
refers to the \tcode{size_type} member type of
10891089
the type deduced by the deduction guide.
10901090

1091+
\pnum
1092+
The types \tcode{iterator} and \tcode{const_iterator} meet
1093+
the constexpr iterator requirements\iref{iterator.requirements.general}.
1094+
10911095
\rSec3[string.require]{General requirements}
10921096

10931097
\pnum

source/support.tex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@
650650
#define @\defnlibxname{cpp_lib_math_constants}@ 201907L // also in \libheader{numbers}
651651
#define @\defnlibxname{cpp_lib_math_special_functions}@ 201603L // also in \libheader{cmath}
652652
#define @\defnlibxname{cpp_lib_memory_resource}@ 201603L // also in \libheader{memory_resource}
653-
#define @\defnlibxname{cpp_lib_monadic_optional}@ 202110L // also in \libheader{optional}
654653
#define @\defnlibxname{cpp_lib_move_only_function}@ 202110L // also in \libheader{functional}
655654
#define @\defnlibxname{cpp_lib_node_extract}@ 201606L
656655
// also in \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set}
@@ -659,7 +658,7 @@
659658
// \libheader{unordered_map}, \libheader{unordered_set}, \libheader{vector}
660659
#define @\defnlibxname{cpp_lib_not_fn}@ 201603L // also in \libheader{functional}
661660
#define @\defnlibxname{cpp_lib_null_iterators}@ 201304L // also in \libheader{iterator}
662-
#define @\defnlibxname{cpp_lib_optional}@ 202106L // also in \libheader{optional}
661+
#define @\defnlibxname{cpp_lib_optional}@ 202110L // also in \libheader{optional}
663662
#define @\defnlibxname{cpp_lib_out_ptr}@ 202106L // also in \libheader{memory}
664663
#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric}
665664
#define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}

0 commit comments

Comments
 (0)