Skip to content

Commit 6d81ed8

Browse files
authored
Merge 2024-11 LWG Motion 1
P3504R0 C++ Standard Library Ready Issues to be moved in Wrocław, Nov. 2024
2 parents 1358c8c + 71389a0 commit 6d81ed8

14 files changed

+199
-146
lines changed

source/algorithms.tex

+25-8
Original file line numberDiff line numberDiff line change
@@ -11167,13 +11167,20 @@
1116711167

1116811168
\pnum
1116911169
Some algorithms specified in \ref{specialized.algorithms}
11170-
make use of the exposition-only function template
11171-
\tcode{\placeholdernc{voidify}}:
11170+
make use of the following exposition-only function templates:
1117211171
\begin{codeblock}
1117311172
template<class T>
1117411173
constexpr void* @\placeholdernc{voidify}@(T& obj) noexcept {
1117511174
return addressof(obj);
1117611175
}
11176+
11177+
template<class I>
11178+
decltype(auto) @\exposid{deref-move}@(I& it) {
11179+
if constexpr (is_lvalue_reference_v<decltype(*it)>)
11180+
return std::move(*it);
11181+
else
11182+
return *it;
11183+
}
1117711184
\end{codeblock}
1117811185

1117911186
\rSec2[special.mem.concepts]{Special memory concepts}
@@ -11550,7 +11557,7 @@
1155011557
\begin{codeblock}
1155111558
for (; first != last; (void)++result, ++first)
1155211559
::new (@\placeholdernc{voidify}@(*result))
11553-
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
11560+
typename iterator_traits<NoThrowForwardIterator>::value_type(@\exposid{deref-move}@(first));
1155411561
return result;
1155511562
\end{codeblock}
1155611563
\end{itemdescr}
@@ -11610,7 +11617,7 @@
1161011617
\begin{codeblock}
1161111618
for (; n > 0; ++result, (void) ++first, --n)
1161211619
::new (@\placeholdernc{voidify}@(*result))
11613-
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
11620+
typename iterator_traits<NoThrowForwardIterator>::value_type(@\exposid{deref-move}@(first));
1161411621
return {first, result};
1161511622
\end{codeblock}
1161611623
\end{itemdescr}
@@ -11741,14 +11748,22 @@
1174111748
\begin{itemdescr}
1174211749
\pnum
1174311750
\constraints
11744-
The expression \tcode{::new (declval<void*>()) T(declval<Args>()...)}
11751+
\tcode{is_unbounded_array_v<T>} is \tcode{false}.
11752+
The expression \tcode{::new (declval<void*>()) T(\linebreak{}declval<Args>()...)}
1174511753
is well-formed when treated as an unevaluated operand\iref{term.unevaluated.operand}.
1174611754

11755+
\pnum
11756+
\mandates
11757+
If \tcode{is_array_v<T>} is \tcode{true}, \tcode{sizeof...(Args)} is zero.
11758+
1174711759
\pnum
1174811760
\effects
1174911761
Equivalent to:
1175011762
\begin{codeblock}
11751-
return ::new (@\placeholdernc{voidify}@(*location)) T(std::forward<Args>(args)...);
11763+
if constexpr (is_array_v<T>)
11764+
return ::new (@\placeholdernc{voidify}@(*location)) T[1]();
11765+
else
11766+
return ::new (@\placeholdernc{voidify}@(*location)) T(std::forward<Args>(args)...);
1175211767
\end{codeblock}
1175311768
\end{itemdescr}
1175411769

@@ -11919,7 +11934,8 @@
1191911934
\begin{itemdecl}
1192011935
template<class R, class G, class D>
1192111936
requires @\libconcept{output_range}@<R, invoke_result_t<D&, G&>> && @\libconcept{invocable}@<D&, G&> &&
11922-
@\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>>
11937+
@\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>> &&
11938+
is_arithmetic_v<invoke_result_t<D&, G&>>
1192311939
constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g, D&& d);
1192411940
\end{itemdecl}
1192511941

@@ -11968,7 +11984,8 @@
1196811984

1196911985
\begin{itemdecl}
1197011986
template<class G, class D, @\libconcept{output_iterator}@<invoke_result_t<D&, G&>> O, @\libconcept{sentinel_for}@<O> S>
11971-
requires @\libconcept{invocable}@<D&, G&> && @\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>>
11987+
requires @\libconcept{invocable}@<D&, G&> && @\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>> &&
11988+
is_arithmetic_v<invoke_result_t<D&, G&>>
1197211989
constexpr O ranges::generate_random(O first, S last, G&& g, D&& d);
1197311990
\end{itemdecl}
1197411991

source/containers.tex

+10-9
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@
14631463
\pnum
14641464
\expects
14651465
\tcode{T} is \oldconcept{EmplaceConstructible} into \tcode{X} from \tcode{args}.
1466-
For \tcode{vector} and \tcode{deque},
1466+
For \tcode{vector}, \tcode{inplace_vector}, and \tcode{deque},
14671467
\tcode{T} is also \oldconcept{MoveInsertable} into \tcode{X} and
14681468
\oldconcept{MoveAssignable}.
14691469

@@ -7200,10 +7200,13 @@
72007200
\rSec3[forward.list.modifiers]{Modifiers}
72017201

72027202
\pnum
7203-
None of the overloads of \tcode{insert_after} shall affect the validity of iterators and
7204-
references, and \tcode{erase_after} shall invalidate only iterators and references to
7205-
the erased elements. If an exception is thrown during \tcode{insert_after} there shall
7206-
be no effect. Inserting \tcode{n} elements into a \tcode{forward_list} is linear in
7203+
The member functions in this subclause
7204+
do not affect the validity of iterators and references
7205+
when inserting elements, and when erasing elements
7206+
invalidate iterators and references to the erased elements only.
7207+
If an exception is thrown by any of these member functions
7208+
there is no effect on the container.
7209+
Inserting \tcode{n} elements into a \tcode{forward_list} is linear in
72077210
\tcode{n}, and the number of calls to the copy or move constructor of \tcode{T} is
72087211
exactly equal to \tcode{n}. Erasing \tcode{n} elements from a \tcode{forward_list} is
72097212
linear in \tcode{n} and the number of calls to the destructor of type \tcode{T} is
@@ -7780,7 +7783,7 @@
77807783
\begin{itemdescr}
77817784
\pnum
77827785
\effects
7783-
Equivalent to: \tcode{return erase_if(c, [\&](auto\& elem) \{ return elem == value; \});}
7786+
Equivalent to: \tcode{return erase_if(c, [\&](const auto\& elem) -> bool \{ return elem == value; \});}
77847787
\end{itemdescr}
77857788

77867789
\indexlibrarymember{erase_if}{forward_list}%
@@ -8564,7 +8567,7 @@
85648567
\begin{itemdescr}
85658568
\pnum
85668569
\effects
8567-
Equivalent to: \tcode{return erase_if(c, [\&](auto\& elem) \{ return elem == value; \});}
8570+
Equivalent to: \tcode{return erase_if(c, [\&](const auto\& elem) -> bool \{ return elem == value; \});}
85688571
\end{itemdescr}
85698572

85708573
\indexlibrarymember{erase_if}{list}%
@@ -9255,8 +9258,6 @@
92559258

92569259
// bit reference
92579260
class @\libmember{reference}{vector<bool>}@ {
9258-
constexpr reference() noexcept;
9259-
92609261
public:
92619262
constexpr reference(const reference&) = default;
92629263
constexpr ~reference();

source/iostreams.tex

+25-20
Original file line numberDiff line numberDiff line change
@@ -6816,7 +6816,7 @@
68166816
\effects
68176817
Equivalent to:
68186818
\begin{codeblock}
6819-
print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
6819+
print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));
68206820
\end{codeblock}
68216821
\end{itemdescr}
68226822

@@ -6854,25 +6854,31 @@
68546854
without regard to the value of \tcode{os.exceptions()} and
68556855
without turning on \tcode{ios_base::badbit} in the error state of \tcode{os}.
68566856
\end{itemize}
6857+
6858+
\par % This paragraph is part of the \effects clause.
68576859
After constructing a \tcode{sentry} object,
68586860
the function initializes a variable with automatic storage duration via
68596861
\begin{codeblock}
68606862
string out = vformat(os.getloc(), fmt, args);
68616863
\end{codeblock}
6864+
\begin{itemize}
6865+
\item
68626866
If the function is \tcode{vprint_unicode} and
6863-
\tcode{os} is a stream that refers to a terminal capable of displaying Unicode
6867+
\tcode{os} is a stream that refers to a terminal that
6868+
is capable of displaying Unicode only via a native Unicode API,
68646869
which is determined in an implementation-defined manner,
6870+
flushes \tcode{os} and then
68656871
writes \tcode{out} to the terminal using the native Unicode API;
68666872
if \tcode{out} contains invalid code units,
68676873
\indextext{undefined}%
6868-
the behavior is undefined and
6869-
implementations are encouraged to diagnose it.
6870-
If the native Unicode API is used,
6871-
the function flushes \tcode{os} before writing \tcode{out}.
6872-
Otherwise (if \tcode{os} is not such a stream or
6873-
the function is \tcode{vprint_nonunicode}),
6874+
the behavior is undefined.
6875+
\item
6876+
Otherwise
68746877
inserts the character sequence
68756878
\range{out.begin()}{out.end()} into \tcode{os}.
6879+
\end{itemize}
6880+
6881+
\par % This paragraph is part of the \effects clause.
68766882
If writing to the terminal or inserting into \tcode{os} fails,
68776883
calls \tcode{os.setstate(ios_base::badbit)}
68786884
(which may throw \tcode{ios_base::failure}).
@@ -7837,28 +7843,27 @@
78377843
Let \tcode{out} denote the character representation of
78387844
formatting arguments provided by \tcode{args}
78397845
formatted according to specifications given in \tcode{fmt}.
7840-
If \tcode{stream} refers to a terminal capable of displaying Unicode,
7846+
\begin{itemize}
7847+
\item
7848+
If \tcode{stream} refers to a terminal that
7849+
is capable of displaying Unicode only via a native Unicode API,
7850+
flushes \tcode{stream} and then
78417851
writes \tcode{out} to the terminal using the native Unicode API;
78427852
if \tcode{out} contains invalid code units,
78437853
\indextext{undefined}%
7844-
the behavior is undefined and
7845-
implementations are encouraged to diagnose it.
7854+
the behavior is undefined.
7855+
\item
78467856
Otherwise writes \tcode{out} to \tcode{stream} unchanged.
7847-
If the native Unicode API is used,
7848-
the function flushes \tcode{stream} before writing \tcode{out}.
7857+
\end{itemize}
78497858
Unconditionally unlocks \tcode{stream} on function exit.
78507859

78517860
\xrefc{7.21.2}.
78527861

78537862
\begin{note}
7854-
On POSIX and Windows, \tcode{stream} referring to a terminal means that,
7855-
respectively,
7856-
\tcode{isatty(fileno(\linebreak{}stream))} and
7863+
On Windows the native Unicode API is \tcode{WriteConsoleW} and
7864+
\tcode{stream} referring to a terminal means that
78577865
\tcode{GetConsoleMode(_get_osfhandle(_fileno(stream)), ...)}
7858-
return nonzero.
7859-
\end{note}
7860-
\begin{note}
7861-
On Windows, the native Unicode API is \tcode{WriteConsoleW}.
7866+
returns nonzero.
78627867
\end{note}
78637868

78647869
\pnum

source/iterators.tex

+1
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,7 @@
19691969
\item \tcode{to_address(a) == addressof(*a)},
19701970
\item \tcode{to_address(b) == to_address(a) + D(b - a)},
19711971
\item \tcode{to_address(c) == to_address(a) + D(c - a)},
1972+
\item \tcode{to_address(I\{\})} is well-defined,
19721973
\item \tcode{ranges::iter_move(a)} has
19731974
the same type, value category, and effects as \tcode{std::move(*a)}, and
19741975
\item if \tcode{ranges::iter_swap(a, b)} is well-formed,

source/memory.tex

+37-23
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,14 @@
20842084
}
20852085
\end{codeblock}
20862086

2087+
\pnum
2088+
A program that instantiates the definition of \tcode{unique_ptr<T, D>}
2089+
is ill-formed if \tcode{T*} is an invalid type.
2090+
\begin{note}
2091+
This prevents the intantiation of specializations such as
2092+
\tcode{unique_ptr<T\&, D>} and \tcode{unique_ptr<int() const, D>}.
2093+
\end{note}
2094+
20872095
\pnum
20882096
The default type for the template parameter \tcode{D} is
20892097
\tcode{default_delete}. A client-supplied template argument
@@ -2434,9 +2442,13 @@
24342442
\end{itemdecl}
24352443

24362444
\begin{itemdescr}
2445+
\pnum
2446+
\mandates
2447+
\tcode{reference_converts_from_temporary_v<add_lvalue_reference_t<T>, decltype(\linebreak{}*declval<pointer>())>} is \tcode{false}.
2448+
24372449
\pnum
24382450
\expects
2439-
\tcode{get() != nullptr}.
2451+
\tcode{get() != nullptr} is \tcode{true}.
24402452

24412453
\pnum
24422454
\returns
@@ -3970,15 +3982,15 @@
39703982
\tcode{allocate_shared} shall initialize this (sub)object
39713983
via the expression
39723984
\begin{itemize}
3973-
\item \tcode{allocator_traits<A2>::construct(a2, pv, v)} or
3974-
\item \tcode{allocator_traits<A2>::construct(a2, pv, l...)}
3985+
\item \tcode{allocator_traits<A2>::construct(a2, pu, v)} or
3986+
\item \tcode{allocator_traits<A2>::construct(a2, pu, l...)}
39753987
\end{itemize}
39763988
respectively,
3977-
where \tcode{pv} points to storage
3978-
suitable to hold an object of type \tcode{U} and
3979-
\tcode{a2} of type \tcode{A2} is a rebound copy of
3980-
the allocator \tcode{a} passed to \tcode{allocate_shared}
3981-
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
3989+
where \tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
3990+
pointing to storage
3991+
suitable to hold an object of type \tcode{remove_cv_t<U>} and
3992+
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
3993+
the allocator \tcode{a} passed to \tcode{allocate_shared}.
39823994
\item
39833995
When a (sub)object of non-array type \tcode{U} is specified to have
39843996
a default initial value,
@@ -3989,13 +4001,13 @@
39894001
\item
39904002
When a (sub)object of non-array type \tcode{U} is specified to have
39914003
a default initial value,
3992-
\tcode{allocate_shared} shall initialize this (sub)object
3993-
via the expression \tcode{allocator_traits<A2>::construct(a2, pv)},
3994-
where \tcode{pv} points to storage
3995-
suitable to hold an object of type \tcode{U} and
3996-
\tcode{a2} of type \tcode{A2} is a rebound copy of
3997-
the allocator \tcode{a} passed to \tcode{allocate_shared}
3998-
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
4004+
\tcode{allocate_shared} initializes this (sub)object
4005+
via the expression \tcode{allocator_traits<A2>::construct(a2, pu)},
4006+
where \tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
4007+
pointing to storage
4008+
suitable to hold an object of type \tcode{remove_cv_t<U>} and
4009+
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
4010+
the allocator \tcode{a} passed to \tcode{allocate_shared}.
39994011
\item
40004012
When a (sub)object of non-array type \tcode{U} is initialized by
40014013
\tcode{make_shared_for_overwrite} or\linebreak % avoid Overfull
@@ -4012,18 +4024,20 @@
40124024
of their original construction.
40134025
\item
40144026
When a (sub)object of non-array type \tcode{U}
4015-
that was initialized by \tcode{make_shared} is to be destroyed,
4016-
it is destroyed via the expression \tcode{pv->\~{}U()} where
4017-
\tcode{pv} points to that object of type \tcode{U}.
4027+
that was initialized by \tcode{make_shared},
4028+
\tcode{make_shared_for_overwrite}, or \tcode{allocate_shared_for_overwrite}
4029+
is to be destroyed,
4030+
it is destroyed via the expression \tcode{pu->\~{}U()} where
4031+
\tcode{pu} points to that object of type \tcode{U}.
40184032
\item
40194033
When a (sub)object of non-array type \tcode{U}
40204034
that was initialized by \tcode{allocate_shared} is to be destroyed,
40214035
it is destroyed via the expression
4022-
\tcode{allocator_traits<A2>::destroy(a2, pv)} where
4023-
\tcode{pv} points to that object of type \tcode{remove_cv_t<U>} and
4024-
\tcode{a2} of type \tcode{A2} is a rebound copy of
4025-
the allocator \tcode{a} passed to \tcode{allocate_shared}
4026-
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
4036+
\tcode{allocator_traits<A2>::destroy(a2, pu)} where
4037+
\tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
4038+
pointing to that object of type \tcode{remove_cv_t<U>} and
4039+
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
4040+
the allocator \tcode{a} passed to \tcode{allocate_shared}.
40274041
\end{itemize}
40284042
\begin{note}
40294043
These functions will typically allocate more memory than \tcode{sizeof(T)} to

source/meta.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@
12171217
For an array type \tcode{T}, the same result as
12181218
\tcode{has_unique_object_representations_v<remove_all_extents_t<T>>},
12191219
otherwise \seebelow. &
1220-
\tcode{T} shall be a complete type, \cv{}~\keyword{void}, or
1221-
an array of unknown bound. \\ \rowsep
1220+
\tcode{remove_all_extents_t<T>} shall be a complete type or
1221+
\cv{}~\keyword{void}. \\ \rowsep
12221222

12231223
\indexlibraryglobal{reference_constructs_from_temporary}%
12241224
\tcode{template<class T, class U>}\br

0 commit comments

Comments
 (0)