auto ref deduction and common type deduction inconsistency

via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 20 09:34:40 PDT 2014


On Wednesday, 20 August 2014 at 15:29:05 UTC, ketmar via 
Digitalmars-d wrote:
> and for (cond ? x : 42) compiler should emit error too, 'cause
> exact return type can't be determined. maybe it should do this 
> only for
> 'auto ref' though.

No, the type of (cond ? x : 42) is always `int`, the `ref` 
already gets lost inside the ternary operator. So in this case, 
it behaves correctly.


More information about the Digitalmars-d mailing list