Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-07-24 03:14:03


>From: "Yitzhak Sapir" <yitzhaks_at_[hidden]>

> It works on MSVC 6.5, which is nice.
> I've never had a need for it, but it would be nice to be able to specify
or pass the stringstream as a parameter.

Yeah. It would let you configure the stringstream.

>If you do a lot of conversions, you could: 1) create a stringstream to be
used for all the conversions, and pass it as a parameter. 2) specify
particular attributes of the stringstream such as decimal point precision.

Yes. I think the first has more chance of success than the latter. When I
first looked into using lexical_cast, it was that I needed to be able to
generate strings with hexadecimal numbers, from integers. So I modified
lexical_cast a little, so that it would be possible to pass a number base
parameter (defaulting to 10). I also sent this to Kevlin for comment. He
said that I wasn't the first to have suggested something like that, but that
such number-specific parameters would actually make it less generic, not
more. Consider if you convert a floating point value to string, what would
the base-specifier be then? It wouldn't make any sense. I admit he has a
point.

This is similar to your point 2, above here. A parameter specifying a
decimal precision would make no sense, if it was used for integers.

I understand that these can be used to configure the stringstream
internally. However, if you're first to pass a parameter, rather than trying
to guess, and cover an incomplete area of the configurations, it could be
better to pass the stringstream, instead. That would let you do any
configuration of it, before passing it. This is your point 1, above here.

However, as mentioned in an earlier posting, as I understand, there was
apparently a consensus that this was not acceptable, when this was
discussed, as well.

So, what is done is to make it more generic, at least, so that it's able to
accept any type, including other character types. As well as fixing its
handling of characters or strings, when these contained whitespace, or empty
strings.

Thanks for the feedback.

Regards,

Terje

> > -----Original Message-----
> > From: tslettebo_at_[hidden] [mailto:tslettebo_at_[hidden]]
> > Sent: Wednesday, July 24, 2002 4:34 AM
> > To: boost_at_[hidden]
> > Subject: Re: [boost] Re: lexical_cast<>() and character traits
> >
> >
> > By the way, until the new version is reviewed by Kevlin, I've
> > put it here
> > (http://groups.yahoo.com/group/boost/files/lexical_cast_propos
> ition.zip). It
> also includes a unit test. That way, it's possible to use it.
>
> Feedback, suggestions, bugreports, etc. is welcome.
>
>
> Regards,
>
> Terje


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