disabling unary "-" for unsigned types
Steven Schveighoffer
schveiguy at yahoo.com
Mon Feb 15 19:17:29 PST 2010
On Mon, 15 Feb 2010 21:32:21 -0500, Rainer Deyke <rainerd at eldwood.com>
wrote:
> Ellery Newcomer wrote:
>> On 02/15/2010 05:33 PM, Steven Schveighoffer wrote:
>>> uint a = -1; // error
>>
>> I can't say I would appreciate having to write
>>
>> uint a = 0xFFFFFFFF;
>>
>> or the equivalent for ulong.
>
> uint a = ~0u;
even ~0 works, no need for the u (although it makes things clearer).
Ellery, you didn't read my original post thoroughly, I said this was the
most common case of wanting to use unary negative on an unsigned value,
and it's easily rewritten, with the same number of characters no less.
-Steve
More information about the Digitalmars-d
mailing list