Skip to content
Snippets Groups Projects
Commit ba4f5530 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Use rvalues in std::string::resize_and_overwrite (LWG 3645)

Previously the C++23 draft required that the callback arguments were
lvalues, which was overvable by the callback. LWG 3645 removes that
overspecification, so we can pass rvalues and the user can't modify
our local variables. I've used auto(p) to produce rvalues, which is only
supported since Clang 15, but I think that's OK for a C++23 feature.

While making this change I noticed that we weren't correctly enforcing
the requirement that the callback returns an integer-like type. Add
better assertions for the type and value.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc (basic_string::resize_and_overwrite):
	Pass rvalues to the callback, as now allowed by LWG 3645.
	Enforce preconditions on the return value.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
	Adjust.
parent 7d4f4ce6
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment