
On 5/2/06, Oleg Abrosimov <beholder@gorodok.net> wrote:
now consider the code snippet again: double d = 2 + (double)from_string("1");
1) is it hard to understand what is going on here? from first glance? after explanation? 2) ??? 3) is it hard to find such constructs in code? {grep from_string} would help. 4) C-style casts won't disappear in any observable time because of interoperability with C.
Mightn't this be better-spelled as: double d = 2 + from_string<double> ("1"); This is exactly as many characters as the C-style cast version, but much more in keeping with modern C++ style (IMHO of course). Is your idea that from_string would return a proxy object that supports e.g. operator double(), operator int(), etc? I think a templated function would be simpler and perhaps more optimal, and provide more opportunity for user-defined conversions. -- Caleb Epstein caleb dot epstein at gmail dot com