The cast(signed), cast(unsigned) feature proposal
Mrzlga
bulletproofchest at gmail.com
Fri Jun 7 17:22:39 PDT 2013
> How about this: if `Foo` is a template with a single type
> parameter that returns a type, writing `cast(Foo)bar` will be
> parsed as `cast(Foo!(typeof(bar))bar`.
My proposal has a bad thing about it:
The 'unsigned' and 'signed' keywords can't be as easily extended
the way that an signed(x) template in the library can: A library
author could just specialize the signed() template to add support
for their own numeric type. To do the same with cast(signed) it
needs to invoke some signed operator on the type, or use your
solution.
I wanted to deal with the cast(int) x; not showing the intention
of "signed". If your cast(SomeTemplate) solution can handle this
as well, then it's better.
I don't actually mind writing signed(x), but I want to think of a
way to discourage people from writing cast(int) x when they are
doing nothing but converting unsigned->signed.
More information about the Digitalmars-d
mailing list