Roland Bock-2 wrote
On 2014-05-26 01:25, Vladimir Batov wrote:
On 05/26/2014 12:59 AM, Thijs (M.A.) van den Berg wrote:
...
In C++11 has std::to_string and various flavours of stoul, stoull, stof. To me it makes more sense to use those for conversions between strings and integral types. Not just because of portability, but also because the interface is so simple.
The value of convert to me seems to be more in the context of generic programming for a wide range of types with a uniform interface than for a simple interface for specific types for which there are already simple & standard alternatives.
If the ability to be used in generic programming is the main value, then why are almost all the examples in the documentation string->int?
Well, clearly there are many reasons the docs are far from satisfactory... You are not suggesting I spend weeks and weeks writing a bestseller just to see all that rejected during the review and going to the rubbish bin, right? So, I had to be mindful of that.
And I was not (knowingly) suggesting API changes that reduce applicability for generic programming. In fact the ability to provide a callable to handle the conversion problems is much better suited than returning a default value and testing for it, IMHO. It is probably also performing better than throwing and catching exceptions.
I never thought of that. It sounds potentially interesting. I myself have no
experience of such deployment... Might be an overkill as so far "optional"
served my purposes well... It'd be easier to see real compilable code with
realistic examples... even if it is merely string->int. ;-)
Many suggestions might well be legit. I just can't possibly try coding all
the suggestions and dealing with and working around all potential issues by
myself. People should start contributing code.
We might start with
namespace boost
{
template