Implicit conversion rules

Maxim Fomin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 21 22:41:28 PDT 2015


On Wednesday, 21 October 2015 at 19:49:35 UTC, Ali Çehreli wrote:
> On 10/21/2015 12:37 PM, Sigg wrote:
>
> > cause at least few more "fun" side effects.
>
> One of those side effects would be function calls binding 
> silently to another overload:
>
> void foo(bool){/* ... */}
> void foo(int) {/* ... */}
>
>   auto a = 0;  // If the type were deduced by the value,
>   foo(a);      // then this would be a call to foo(bool)...
>                // until someone changed the value to 2. :)
>
> Ali

Actually 'a' is deduced to be int, so int version is called (as 
expected?). See my example above for the VRO overload issue.


More information about the Digitalmars-d-learn mailing list