Re: minElement on array of const objects

2017-11-14 Thread Aurelien Fredouelle via Digitalmars-d-learn
On Monday, 13 November 2017 at 14:28:27 UTC, vit wrote: On Monday, 13 November 2017 at 12:15:26 UTC, Nathan S. wrote: [...] Is Unqual necessary here?: https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1284 https://github.com/dlang/phobos/blob/master/std/algorithm/searching

Re: minElement on array of const objects

2017-11-13 Thread vit via Digitalmars-d-learn
On Monday, 13 November 2017 at 12:15:26 UTC, Nathan S. wrote: Unqual!Element seed = r.front; alias MapType = Unqual!(typeof(mapFun(CommonElement.init))); This looks like a job for std.typecons.Rebindable!(const A) instead of Unqual!(const A) which is used currently. I am surprised that thi

Re: minElement on array of const objects

2017-11-13 Thread Nathan S. via Digitalmars-d-learn
Unqual!Element seed = r.front; alias MapType = Unqual!(typeof(mapFun(CommonElement.init))); This looks like a job for std.typecons.Rebindable!(const A) instead of Unqual!(const A) which is used currently. I am surprised that this is the first time anyone has run into this.

Re: minElement on array of const objects

2017-11-13 Thread Temtaime via Digitalmars-d-learn
On Monday, 13 November 2017 at 10:20:51 UTC, Aurelien Fredouelle wrote: Hi all, It seems that it is not possible to use minElement on an array of const objects: class A { int val; } const(A) doStuff(const(A)[] v) { import std.algorithm.searching : minElement; return v.minElement!"a.val

minElement on array of const objects

2017-11-13 Thread Aurelien Fredouelle via Digitalmars-d-learn
Hi all, It seems that it is not possible to use minElement on an array of const objects: class A { int val; } const(A) doStuff(const(A)[] v) { import std.algorithm.searching : minElement; return v.minElement!"a.val"; } This gets the following compiler error: std/algorithm/searching.d(