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

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:

Alias this and inheritance

2017-11-05 Thread Aurelien Fredouelle via Digitalmars-d-learn
The following code does not compile: struct S { } class A { S s; alias s this; } class B : A { } void main() { A asA = new B; B asB = cast(B)asA; } I would expect the last line to successfully cast the B instance I created back into type B, however this seems to be preempted by the