Boost logo

Boost :

Subject: [boost] [Convert] Not a review
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-05-03 18:47:24


Dear All,

I've not looked at this library in anything like enough detail to write
a proper review, though I have followed a fair amount of the discussion
both during the review and during previous discussions of a "better lexical_cast".

My view comes down to this: there are zillions of different ways of
doing this (both syntax and semantics) and no solution can keep
everyone happy (as evidenced particularly by the previous
discussions). But that doesn't matter, because every single C++
programmer is capable of writing their own conversion functions that
work exactly how they want them to work, if they have the right
building blocks.

The building blocks are things like C's strto*(), etc. Personally, I
prefer thin wrappers like these ones:

template <typename ITER>
long int strtol(ITER begin, ITER end)
{
   ...
}

template <int N>
long int strtol(const char (&s) [N])
{
   return strtol(&s[0],&s[N]);
}

inline long int strtol(std::string s)
{
   return strtol(s.begin(),s.end());
}

For variations on error policy I add words like "try", "must" or
"maybe" to the function name; similarly for hex and other variations.
But I don't suggest that these are going to suit other people. Why
should we try to find a "one size fits all" solution to this problem?
In my humble opinion, Boost does not need this functionality.

Perhaps some of the lower-level "building blocks" would be useful,
though - if things like strto*() are deficient.

Regards, Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk