const debacle

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 24 12:35:19 PDT 2008


"Janice Caron" wrote
> On 24/03/2008, Craig Black wrote:
>> I must have missed something.  What's wrong with this:
>>
>>  T min(T)(const T a, const T b) { return a < b ? a : b; }
>
> Surely, that won't compile, because the type of (a < b ? a : b) is
> const(T), and const(T) won't implicitly convert to T.

Well, with the latest version of DMD, it will for value types that are not 
pointers, but not for ones that are reference or pointer types :)

i.e. compiles for int, not for class C

Of course, your point is correct, it doesn't work how you want it to.

-Steve 





More information about the Digitalmars-d mailing list