Bug 18036 – Documentation of moveFront() fails to mention different behavior depending on hasElaborateCopyConstructor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-05T19:47:05Z
Last change time
2022-02-28T12:36:42Z
Keywords
pull
Assigned to
No Owner
Creator
Ali Cehreli

Comments

Comment #0 by acehreli — 2017-12-05T19:47:05Z
The source code uses hasElaborateCopyConstructor: ElementType!R moveFront(R)(R r) { static if (is(typeof(&r.moveFront))) { return r.moveFront(); } else static if (!hasElaborateCopyConstructor!(ElementType!R)) { return r.front; } else static if (is(typeof(&(r.front())) == ElementType!R*)) { import std.algorithm.mutation : move; return move(r.front); } else { static assert(0, "Cannot move front of a range with a postblit and an rvalue front."); } } but the documentation ignores that fact. Ali
Comment #1 by acehreli — 2017-12-05T19:52:38Z
To add, the users are surprised that the source object is not set to .init in some cases.
Comment #2 by dlang-bot — 2022-02-25T01:57:18Z
@pbackus created dlang/phobos pull request #8393 "Fix Issue 18036 - Documentation of moveFront()" fixing this issue: - Fix Issue 18036 - Documentation of moveFront() ...fails to mention different behavior depending on hasElaborateCopyConstructor The new wording is based on the documentation for core.lifetime.move. https://github.com/dlang/phobos/pull/8393
Comment #3 by dlang-bot — 2022-02-28T12:36:42Z
dlang/phobos pull request #8393 "Fix Issue 18036 - Documentation of moveFront()" was merged into master: - aefeca17e7b3f39ea00777cafa5b920ca54f7c3d by Paul Backus: Fix Issue 18036 - Documentation of moveFront() ...fails to mention different behavior depending on hasElaborateCopyConstructor The new wording is based on the documentation for core.lifetime.move. https://github.com/dlang/phobos/pull/8393