digitalmars.D.learn - std.algorithm.sort with copy constructors
- Gregor =?UTF-8?B?TcO8Y2ts?= (26/26) Apr 13 2020 Hi!
- Steven Schveighoffer (6/21) Apr 13 2020 This is a bug in phobos.
- Steven Schveighoffer (3/6) Apr 13 2020 https://github.com/dlang/phobos/pull/7442
- Gregor =?UTF-8?B?TcO8Y2ts?= (6/12) Apr 14 2020 Sorry for sending you down that particular rabbit hole. And a big
Hi! Consider the following code: --- import std; struct S { pure this(ref return scope const S rhs) nothrow nogc { this.x = x; } int x; } void main() { S[] array = new S[10]; array.sort!("a.x < b.x", SwapStrategy.stable); } --- In this program, sort compiles only if the copy constructor is decorated with pure, nothrow and nogc. This is very limiting. Is there a way to get rid of nothrow and nogc on the copy constructor and still use sort? My actual use case, inefficient as it may be, is to sort structs that use copy constructors to enforce deep copies of their contents. So there's liberal use of .dup in them, which obviously is neither nothrow nor nogc. Cheers, Gregor
Apr 13 2020
On 4/13/20 9:27 AM, Gregor Mückl wrote:import std; struct S { pure this(ref return scope const S rhs) nothrow nogc { this.x = x; } int x; } void main() { S[] array = new S[10]; array.sort!("a.x < b.x", SwapStrategy.stable); }This is a bug in phobos. https://issues.dlang.org/show_bug.cgi?id=20732 Also went down a rabbit hole due to this: https://issues.dlang.org/show_bug.cgi?id=20733 -Steve
Apr 13 2020
On 4/13/20 10:24 AM, Steven Schveighoffer wrote:This is a bug in phobos. https://issues.dlang.org/show_bug.cgi?id=20732https://github.com/dlang/phobos/pull/7442 -Steve
Apr 13 2020
On Monday, 13 April 2020 at 15:38:33 UTC, Steven Schveighoffer wrote:On 4/13/20 10:24 AM, Steven Schveighoffer wrote:Sorry for sending you down that particular rabbit hole. And a big thank you for following through! I worked around that problem in my use case, but it's good to see one a couple of bugs squashed. :)This is a bug in phobos. https://issues.dlang.org/show_bug.cgi?id=20732https://github.com/dlang/phobos/pull/7442 -Steve
Apr 14 2020