Skip to content

[LWG 1] P3504R0 C++ Standard Library Ready Issues #7459

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

Merged
merged 35 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
aac3b83
LWG3436 std::construct_at should support arrays
burblebee Nov 28, 2024
a89d79c
LWG3899 co_yielding elements of an lvalue generator is unnecessarily …
burblebee Nov 28, 2024
33d88c0
LWG3900 The allocator_arg_t overloads of generator::promise_type::ope…
burblebee Nov 28, 2024
52cec15
LWG3918 std::uninitialized_move/_n and guaranteed copy elision
burblebee Nov 28, 2024
80e7c93
LWG4014 LWG 3809 changes behavior of some existing std::subtract_with…
burblebee Nov 28, 2024
8a74ecf
LWG4024 Underspecified destruction of objects created in std::make_sh…
burblebee Nov 28, 2024
a5e9c4a
LWG4027 possibly-const-range should prefer returning const R&
burblebee Nov 28, 2024
ce924b8
LWG4044 Confusing requirements for std::print on POSIX platforms
burblebee Nov 28, 2024
3bd0db6
[ostream.formatted.print, print.fun] Move "only" to a clearer place
burblebee Dec 13, 2024
245bf7e
LWG4064 Clarify that std::launder is not needed when using the result…
burblebee Nov 28, 2024
fbbfbcb
LWG4072 std::optional comparisons: constrain harder
burblebee Nov 28, 2024
7fba1c5
LWG4085 ranges::generate_random's helper lambda should specify the re…
burblebee Nov 28, 2024
9e856c2
LWG4112 has-arrow should required operator->() to be const-qualified
burblebee Nov 28, 2024
7f1eb2c
LWG4134 Issue with Philox algorithm specification
burblebee Nov 28, 2024
bda434e
LWG4154 The Mandates for std::packaged_task's constructor from a call…
burblebee Nov 28, 2024
3637c13
LWG4164 Missing guarantees for forward_list modifiers
burblebee Nov 28, 2024
2abba45
LWG3216 Rebinding the allocator before calling construct/destroy in a…
burblebee Nov 28, 2024
6082785
LWG3886 Monad mo' problems
burblebee Nov 28, 2024
4afe797
LWG4084 std::fixed ignores std::uppercase
burblebee Nov 28, 2024
033df23
LWG4088 println ignores the locale imbued in std::ostream
burblebee Nov 28, 2024
bc9e865
LWG4113 Disallow has_unique_object_representations<Incomplete[]>
burblebee Nov 28, 2024
62b187f
LWG4119 generator::promise_type::yield_value(ranges::elements_of<R, A…
burblebee Nov 28, 2024
10a3383
LWG4124 Cannot format zoned_time with resolution coarser than seconds
burblebee Nov 28, 2024
b9149a7
LWG4126 Some feature-test macros for fully freestanding features are …
burblebee Nov 28, 2024
f7b2b32
LWG4135 The helper lambda of std::erase for list should specify retur…
burblebee Nov 28, 2024
baec71d
LWG4140 Useless default constructors for bit reference types
burblebee Nov 28, 2024
3abc16b
LWG4141 Improve prohibitions on "additional storage"
burblebee Nov 28, 2024
7a54d69
LWG4142 format_parse_context::check_dynamic_spec should require at le…
burblebee Nov 28, 2024
5fb4d20
LWG4144 Disallow unique_ptr<T&, D>
burblebee Nov 28, 2024
d6a8c67
LWG4147 Precondition on inplace_vector::emplace
burblebee Nov 28, 2024
7226952
LWG4148 unique_ptr::operator* should not allow dangling references
burblebee Nov 28, 2024
6b9f90d
LWG4153 Fix extra "-1" for philox_engine::max()
burblebee Nov 28, 2024
ad3fd01
LWG4157 The resolution of LWG3465 was damaged by P2167R3
burblebee Nov 28, 2024
d509d68
LWG4169 std::atomic<T>'s default constructor should be constrained
burblebee Nov 28, 2024
71389a0
LWG4170 contiguous_iterator should require to_address(I{})
burblebee Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11167,13 +11167,20 @@

\pnum
Some algorithms specified in \ref{specialized.algorithms}
make use of the exposition-only function template
\tcode{\placeholdernc{voidify}}:
make use of the following exposition-only function templates:
\begin{codeblock}
template<class T>
constexpr void* @\placeholdernc{voidify}@(T& obj) noexcept {
return addressof(obj);
}

template<class I>
decltype(auto) @\exposid{deref-move}@(I& it) {
if constexpr (is_lvalue_reference_v<decltype(*it)>)
return std::move(*it);
else
return *it;
}
\end{codeblock}

\rSec2[special.mem.concepts]{Special memory concepts}
Expand Down Expand Up @@ -11550,7 +11557,7 @@
\begin{codeblock}
for (; first != last; (void)++result, ++first)
::new (@\placeholdernc{voidify}@(*result))
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
typename iterator_traits<NoThrowForwardIterator>::value_type(@\exposid{deref-move}@(first));
return result;
\end{codeblock}
\end{itemdescr}
Expand Down Expand Up @@ -11610,7 +11617,7 @@
\begin{codeblock}
for (; n > 0; ++result, (void) ++first, --n)
::new (@\placeholdernc{voidify}@(*result))
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
typename iterator_traits<NoThrowForwardIterator>::value_type(@\exposid{deref-move}@(first));
return {first, result};
\end{codeblock}
\end{itemdescr}
Expand Down Expand Up @@ -11741,14 +11748,22 @@
\begin{itemdescr}
\pnum
\constraints
The expression \tcode{::new (declval<void*>()) T(declval<Args>()...)}
\tcode{is_unbounded_array_v<T>} is \tcode{false}.
The expression \tcode{::new (declval<void*>()) T(\linebreak{}declval<Args>()...)}
is well-formed when treated as an unevaluated operand\iref{term.unevaluated.operand}.

\pnum
\mandates
If \tcode{is_array_v<T>} is \tcode{true}, \tcode{sizeof...(Args)} is zero.

\pnum
\effects
Equivalent to:
\begin{codeblock}
return ::new (@\placeholdernc{voidify}@(*location)) T(std::forward<Args>(args)...);
if constexpr (is_array_v<T>)
return ::new (@\placeholdernc{voidify}@(*location)) T[1]();
else
return ::new (@\placeholdernc{voidify}@(*location)) T(std::forward<Args>(args)...);
\end{codeblock}
\end{itemdescr}

Expand Down Expand Up @@ -11919,7 +11934,8 @@
\begin{itemdecl}
template<class R, class G, class D>
requires @\libconcept{output_range}@<R, invoke_result_t<D&, G&>> && @\libconcept{invocable}@<D&, G&> &&
@\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>>
@\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>> &&
is_arithmetic_v<invoke_result_t<D&, G&>>
constexpr borrowed_iterator_t<R> ranges::generate_random(R&& r, G&& g, D&& d);
\end{itemdecl}

Expand Down Expand Up @@ -11968,7 +11984,8 @@

\begin{itemdecl}
template<class G, class D, @\libconcept{output_iterator}@<invoke_result_t<D&, G&>> O, @\libconcept{sentinel_for}@<O> S>
requires @\libconcept{invocable}@<D&, G&> && @\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>>
requires @\libconcept{invocable}@<D&, G&> && @\libconcept{uniform_random_bit_generator}@<remove_cvref_t<G>> &&
is_arithmetic_v<invoke_result_t<D&, G&>>
constexpr O ranges::generate_random(O first, S last, G&& g, D&& d);
\end{itemdecl}

Expand Down
19 changes: 10 additions & 9 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@
\pnum
\expects
\tcode{T} is \oldconcept{EmplaceConstructible} into \tcode{X} from \tcode{args}.
For \tcode{vector} and \tcode{deque},
For \tcode{vector}, \tcode{inplace_vector}, and \tcode{deque},
\tcode{T} is also \oldconcept{MoveInsertable} into \tcode{X} and
\oldconcept{MoveAssignable}.

Expand Down Expand Up @@ -7200,10 +7200,13 @@
\rSec3[forward.list.modifiers]{Modifiers}

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

\indexlibrarymember{erase_if}{forward_list}%
Expand Down Expand Up @@ -8564,7 +8567,7 @@
\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return erase_if(c, [\&](auto\& elem) \{ return elem == value; \});}
Equivalent to: \tcode{return erase_if(c, [\&](const auto\& elem) -> bool \{ return elem == value; \});}
\end{itemdescr}

\indexlibrarymember{erase_if}{list}%
Expand Down Expand Up @@ -9255,8 +9258,6 @@

// bit reference
class @\libmember{reference}{vector<bool>}@ {
constexpr reference() noexcept;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, the friend declarations were removed by #6427

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, appreciated!


public:
constexpr reference(const reference&) = default;
constexpr ~reference();
Expand Down
45 changes: 25 additions & 20 deletions source/iostreams.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6816,7 +6816,7 @@
\effects
Equivalent to:
\begin{codeblock}
print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));
\end{codeblock}
\end{itemdescr}

Expand Down Expand Up @@ -6854,25 +6854,31 @@
without regard to the value of \tcode{os.exceptions()} and
without turning on \tcode{ios_base::badbit} in the error state of \tcode{os}.
\end{itemize}

\par % This paragraph is part of the \effects clause.
After constructing a \tcode{sentry} object,
the function initializes a variable with automatic storage duration via
\begin{codeblock}
string out = vformat(os.getloc(), fmt, args);
\end{codeblock}
\begin{itemize}
\item
If the function is \tcode{vprint_unicode} and
\tcode{os} is a stream that refers to a terminal capable of displaying Unicode
\tcode{os} is a stream that refers to a terminal that
is capable of displaying Unicode only via a native Unicode API,
which is determined in an implementation-defined manner,
flushes \tcode{os} and then
writes \tcode{out} to the terminal using the native Unicode API;
if \tcode{out} contains invalid code units,
\indextext{undefined}%
the behavior is undefined and
implementations are encouraged to diagnose it.
If the native Unicode API is used,
the function flushes \tcode{os} before writing \tcode{out}.
Otherwise (if \tcode{os} is not such a stream or
the function is \tcode{vprint_nonunicode}),
the behavior is undefined.
\item
Otherwise
inserts the character sequence
\range{out.begin()}{out.end()} into \tcode{os}.
\end{itemize}

\par % This paragraph is part of the \effects clause.
If writing to the terminal or inserting into \tcode{os} fails,
calls \tcode{os.setstate(ios_base::badbit)}
(which may throw \tcode{ios_base::failure}).
Expand Down Expand Up @@ -7837,28 +7843,27 @@
Let \tcode{out} denote the character representation of
formatting arguments provided by \tcode{args}
formatted according to specifications given in \tcode{fmt}.
If \tcode{stream} refers to a terminal capable of displaying Unicode,
\begin{itemize}
\item
If \tcode{stream} refers to a terminal that
is capable of displaying Unicode only via a native Unicode API,
flushes \tcode{stream} and then
writes \tcode{out} to the terminal using the native Unicode API;
if \tcode{out} contains invalid code units,
\indextext{undefined}%
the behavior is undefined and
implementations are encouraged to diagnose it.
the behavior is undefined.
\item
Otherwise writes \tcode{out} to \tcode{stream} unchanged.
If the native Unicode API is used,
the function flushes \tcode{stream} before writing \tcode{out}.
\end{itemize}
Unconditionally unlocks \tcode{stream} on function exit.

\xrefc{7.21.2}.

\begin{note}
On POSIX and Windows, \tcode{stream} referring to a terminal means that,
respectively,
\tcode{isatty(fileno(\linebreak{}stream))} and
On Windows the native Unicode API is \tcode{WriteConsoleW} and
\tcode{stream} referring to a terminal means that
\tcode{GetConsoleMode(_get_osfhandle(_fileno(stream)), ...)}
return nonzero.
\end{note}
\begin{note}
On Windows, the native Unicode API is \tcode{WriteConsoleW}.
returns nonzero.
\end{note}

\pnum
Expand Down
1 change: 1 addition & 0 deletions source/iterators.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,7 @@
\item \tcode{to_address(a) == addressof(*a)},
\item \tcode{to_address(b) == to_address(a) + D(b - a)},
\item \tcode{to_address(c) == to_address(a) + D(c - a)},
\item \tcode{to_address(I\{\})} is well-defined,
\item \tcode{ranges::iter_move(a)} has
the same type, value category, and effects as \tcode{std::move(*a)}, and
\item if \tcode{ranges::iter_swap(a, b)} is well-formed,
Expand Down
60 changes: 37 additions & 23 deletions source/memory.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,14 @@
}
\end{codeblock}

\pnum
A program that instantiates the definition of \tcode{unique_ptr<T, D>}
is ill-formed if \tcode{T*} is an invalid type.
\begin{note}
This prevents the intantiation of specializations such as
\tcode{unique_ptr<T\&, D>} and \tcode{unique_ptr<int() const, D>}.
\end{note}

\pnum
The default type for the template parameter \tcode{D} is
\tcode{default_delete}. A client-supplied template argument
Expand Down Expand Up @@ -2434,9 +2442,13 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
\mandates
\tcode{reference_converts_from_temporary_v<add_lvalue_reference_t<T>, decltype(\linebreak{}*declval<pointer>())>} is \tcode{false}.

\pnum
\expects
\tcode{get() != nullptr}.
\tcode{get() != nullptr} is \tcode{true}.

\pnum
\returns
Expand Down Expand Up @@ -3970,15 +3982,15 @@
\tcode{allocate_shared} shall initialize this (sub)object
via the expression
\begin{itemize}
\item \tcode{allocator_traits<A2>::construct(a2, pv, v)} or
\item \tcode{allocator_traits<A2>::construct(a2, pv, l...)}
\item \tcode{allocator_traits<A2>::construct(a2, pu, v)} or
\item \tcode{allocator_traits<A2>::construct(a2, pu, l...)}
\end{itemize}
respectively,
where \tcode{pv} points to storage
suitable to hold an object of type \tcode{U} and
\tcode{a2} of type \tcode{A2} is a rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
where \tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
pointing to storage
suitable to hold an object of type \tcode{remove_cv_t<U>} and
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}.
\item
When a (sub)object of non-array type \tcode{U} is specified to have
a default initial value,
Expand All @@ -3989,13 +4001,13 @@
\item
When a (sub)object of non-array type \tcode{U} is specified to have
a default initial value,
\tcode{allocate_shared} shall initialize this (sub)object
via the expression \tcode{allocator_traits<A2>::construct(a2, pv)},
where \tcode{pv} points to storage
suitable to hold an object of type \tcode{U} and
\tcode{a2} of type \tcode{A2} is a rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
\tcode{allocate_shared} initializes this (sub)object
via the expression \tcode{allocator_traits<A2>::construct(a2, pu)},
where \tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
pointing to storage
suitable to hold an object of type \tcode{remove_cv_t<U>} and
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}.
\item
When a (sub)object of non-array type \tcode{U} is initialized by
\tcode{make_shared_for_overwrite} or\linebreak % avoid Overfull
Expand All @@ -4012,18 +4024,20 @@
of their original construction.
\item
When a (sub)object of non-array type \tcode{U}
that was initialized by \tcode{make_shared} is to be destroyed,
it is destroyed via the expression \tcode{pv->\~{}U()} where
\tcode{pv} points to that object of type \tcode{U}.
that was initialized by \tcode{make_shared},
\tcode{make_shared_for_overwrite}, or \tcode{allocate_shared_for_overwrite}
is to be destroyed,
it is destroyed via the expression \tcode{pu->\~{}U()} where
\tcode{pu} points to that object of type \tcode{U}.
\item
When a (sub)object of non-array type \tcode{U}
that was initialized by \tcode{allocate_shared} is to be destroyed,
it is destroyed via the expression
\tcode{allocator_traits<A2>::destroy(a2, pv)} where
\tcode{pv} points to that object of type \tcode{remove_cv_t<U>} and
\tcode{a2} of type \tcode{A2} is a rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}
such that its \tcode{value_type} is \tcode{remove_cv_t<U>}.
\tcode{allocator_traits<A2>::destroy(a2, pu)} where
\tcode{pu} is a pointer of type \tcode{remove_cv_t<U>*}
pointing to that object of type \tcode{remove_cv_t<U>} and
\tcode{a2} of type \tcode{A2} is a potentially rebound copy of
the allocator \tcode{a} passed to \tcode{allocate_shared}.
\end{itemize}
\begin{note}
These functions will typically allocate more memory than \tcode{sizeof(T)} to
Expand Down
4 changes: 2 additions & 2 deletions source/meta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,8 @@
For an array type \tcode{T}, the same result as
\tcode{has_unique_object_representations_v<remove_all_extents_t<T>>},
otherwise \seebelow. &
\tcode{T} shall be a complete type, \cv{}~\keyword{void}, or
an array of unknown bound. \\ \rowsep
\tcode{remove_all_extents_t<T>} shall be a complete type or
\cv{}~\keyword{void}. \\ \rowsep

\indexlibraryglobal{reference_constructs_from_temporary}%
\tcode{template<class T, class U>}\br
Expand Down
Loading
Loading