On Thursday, 30 October 2014 at 20:06:30 UTC, H. S. Teoh via
Digitalmars-d wrote:
D had it right by moving all these user-defined literals into
strings
that are parsed at compile-time. Much more powerful than the
crippled
stuff operator""() can accept, and far less dangerous and
lightyears
more maintainable.
I believe there are examples of system software going wrong
because one library used SI units and another one did not. So
being able to typecast doubles into something more restricted is
useful:
3.0_miles vs 3.0_km
Sure you could have done it this way instead:
miles(3.0) vs km(3.0)
But people don't, so providing literals is a good addition for
C++.
(And no, string processing at compile time is not a good idea! It
suffers from the same problems as macros.)