Is opCast need, we have to!
Jonathan M Davis
jmdavisProg at gmx.com
Thu Dec 2 10:35:35 PST 2010
On Thursday, December 02, 2010 02:23:23 foobar wrote:
> My suggestion is much simpler than c++.
> the _language_ needs only to provide two operators:
> down cast operator and const cast operator.
> interpret cast is a corner case that can also be implemented as a library
> utility. conversions can and should be done with regular D code
> (functions). which is not far from current D idioms (to!).
Personally, I think that const_cast is _the_ most pointless cast operator of the
lot. Simply cast, and if const is part of the new type and wasn't part of the
old one, then it's adding const-ness. If const isn't part of the new type and it
was part of the old one, then it's removing constness. Adding the extra
complexity just to make sure that you didn't accidentally add or remove const
seems to be totally overkill to me. And since casting away const in D is
technically undefined behavior anyway, does it even make sense to add a specific
operator for it?
- Jonathan M Davis
More information about the Digitalmars-d
mailing list