phobos/std/algorithm
Jonathan M Davis f0c3e4a66b
Fix Bugzilla issue 24827: maxElement does not handle opAssign correctly. (#9067)
Rebindable2 did not handle types with opAssign correctly, which affected
both minElement and maxElement. Namely, Rebindable2 assigned to memory
which was not properly initialized when the correct solution in such a
situation is to use copyEmplace. Assignment works when assignment is
just a memcpy, but in the general case, opAssign needs to have a
properly initialized object in order to work correctly. copyEmplace
instead copies the object and then places the copy into the unitialized
memory, so it avoids assigning to uninitialized memory.

This commit also adds additional tests for types with destructors (which
do get opAssign automatically) and types with postblit constructors or
copy constructors to try to ensure that the code is doing the correct
thing in those cases with regards to copying, assignment, and
destruction.

https://issues.dlang.org/show_bug.cgi?id=24829 was found in the process,
and this does not fix that. Namely, types which cannot be assigned to
and which also have a postblit constructor or copy constructor do not
get copied correctly. So, among the tests added here are commented out
tests for that case, since they're an altered version of some of the
enabled tests. However, fixing that issue would be involved enough that
I'm not attempting to fix it at this time.
2024-10-27 01:16:22 -07:00
..
comparison.d Better std.algorithm.comparison.clamp error messages 2023-03-15 16:53:20 +01:00
internal.d Add explanatory comment to addressOf 2022-02-07 16:29:58 +00:00
iteration.d CheckBy postblit should be scope 2024-02-12 09:24:07 +01:00
mutation.d [std.algorithm.mutation] Improve remove docs 2024-02-10 12:34:45 +00:00
package.d Fix Issue 20397 2023-02-01 00:44:25 +01:00
searching.d Fix Bugzilla issue 24827: maxElement does not handle opAssign correctly. (#9067) 2024-10-27 01:16:22 -07:00
setops.d Fix some invalid links (#8994) 2024-04-29 22:08:10 +08:00
sorting.d algorithm/sorting: Fix typo introduced in PR #8678 2023-02-18 14:33:49 +00:00