Boost logo

Boost :

Subject: Re: [boost] [Convert] Not a review
From: Max Sobolev (macsmr_at_[hidden])
Date: 2011-05-05 02:12:09


On 04.05.2011 2:47, Phil Endecott wrote:
> 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.

:/ ugly

forget about std C library, its naming conventions and C's idioms in
general.

boost::lexical_cast<> (and std::stringstream), in comparison, support
conversions from *any* IStreamable to *any* OStreamable, but your tool
convert from raw char-representation to long only! Hundred steps back!

for raw-to-int conversion you propose strtoi() name???
for raw-to-double strtod?
...and so on...

this "approach" is useless in a generic code context

you must use function overloading (with the sole *nice* name) instead of
producing a large amount of ugly names that makes excess pressure on mind


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