Skip to content
Snippets Groups Projects
Unverified Commit 95c7a61a authored by Giuseppe D'Angelo's avatar Giuseppe D'Angelo Committed by Jonathan Wakely
Browse files

libstdc++: port the ranges::uninitialized_* algorithms away from is_trivial


In preparation for the deprecation of is_trivial (P3247R2).
The rangified uninitialized_* specialized memory algorithms have code
paths where they call the non-uninitialized versions, because the latter
are usually optimized. The detection in these code paths uses is_trivial;
port it away from it towards more specific checks.

The detection for the copy/move algorithms was suspicious: it checked
that the output type was trivial, and that assignment from the input
range reference type was nothrow. If so, the algorithm would copy/move
assign (by calling the ranges::copy/move algorithms) instead of
constructing elements. I think this is off because:

1) the constructor that would be called by the algorithm (which may be
   neither a copy or a move constructor) wasn't checked. If that
   constructor isn't trivial the caller might detect that we're not
   calling it, and that goes against the algorithms' specifications.
2) a nothrow assignment is necessary but not sufficient, as again we
   need to check for triviality, or the caller can detect we're calling
   an assignment operator we were never meant to be calling from these
   algorithms.

Therefore I've amended the respective detections.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_uninitialized.h: port some if
	constexpr away from is_trivial, and towards more specific
	detections instead.

Signed-off-by: default avatarGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
parent e4a0157c
No related branches found
No related tags found
Loading
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