[Issue 9947] reduce of an array of structs with an immutable field
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 25 12:29:48 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9947
--- Comment #3 from monarchdodra at gmail.com 2014-02-25 12:29:47 PST ---
(In reply to comment #1)
> Using DMD32 v2.061 on Windows 32bit, below doesn't work too.
> I think this is the same issue:
> -----
> import std.stdio;
> import std.algorithm : sort;
>
> struct S
> {
> immutable int x;
> }
>
> void main()
> {
> auto arr = [S(0), S(2), S(1)];
> sort!((a, b) => a.x < b.x)(arr);
> arr.writeln();
> }
> -----
Indeed. But in this case, `arr` is *simply* not sortable: Not without mutating
the immutable.
This is fixed now though:
Error: template std.algorithm.sort cannot deduce function from argument types
!((a, b) => a.x < b.x)(S[])
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list