
On Thu, May 05, 2005 at 10:29:07AM -0500, Dave Dribin wrote:
On May 3, 2005, at 3:27 AM, Kevlin Henney wrote:
I'd be interested to hear your ideas.
Since it sounds like the main argument against adding a second argument is that it is no longer cast-like, the simplest idea is to rename lexical_cast so it is no longer cast-like. I was thinking convert_to would be nice and readable:
int n = convert_to<int>("abc"); // Should throw an exception... bad_conversion? int n = convert_to<int>("abc", 0); // Should return 0
string s = convert_to<string>(5);
The main issue with renaming, obviously, is backward compatibility. Of course, there's no need to remove lexical_cast right away, or at all, even. Maybe make it deprecated, or at least implemented in terms of convert_to.
If you want a function with a different name and a different behaviour, isn't that a different function? In which case, why even consider removing lexical_cast ? jon