digitalmars.D.bugs - [Issue 20732] New: swap doesn't support types with impure gc or
- d-bugmail puremagic.com (31/31) Apr 13 2020 https://issues.dlang.org/show_bug.cgi?id=20732
https://issues.dlang.org/show_bug.cgi?id=20732 Issue ID: 20732 Summary: swap doesn't support types with impure gc or throwing copy constructors Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: schveiguy yahoo.com struct S { this(ref const S other) {} } void main() { import std.alglorithm; S s; swap(s, s); } /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2824): Error: pure function std.algorithm.mutation.swap!(S).swap cannot call impure copy constructor onlineapp.S.this The offending line is here: https://github.com/dlang/phobos/blob/c4f9c18ca788cf4bdb57344681f302d8f1309f36/std/algorithm/mutation.d#L2824 swap works around elaborate assignment but not elaborate construction. --
Apr 13 2020