Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2005-01-30 18:30:56

>From: "Preston A. Elder" <prez_at_[hidden]>

> On Sun, 30 Jan 2005 13:45:21 +0100, Kevlin Henney wrote:
> > Yes, lexical_cast unsets the skipping of whitespace, but that does not,
> > to my knowledge, introduce problems for correctly written stream
> > extraction operators.

> Is it so hard to have lexical_cast have an OPTIONAL second template
> argument of the std::ios::fmtflags to use (defaulting to the default
> fmtflags, which is skipws) - and only do the ">> std::ws" which we do if
> skipws is turned on in the fmtflags we are to use?

When this has been discussed before, other requests for conversion
customisation has also come up, such as being able to use a different
locale, or other stream customisations not available from just the format
flags (such as setting the number base, or other number formatting).
Therefore, if something were to be optionally passable, maybe it should be a
full stream object? (which reminded me of this one: :) )

However, passing a stream may be a little hard to implement, as you can't
bind a default argument to a non-const reference, so the following won't

template<typename Target, typename Source>
Target lexical_cast(const Source &arg,
   std::basic_stringstream<typename detail::select_stream_char<Source,
Target>::type> &stream =
   std::basic_stringstream<typename detail::select_stream_char<Source,

("select_stream_char<>" is made up for the occasion; it contains the typedef
for char_type in lexical_stream)



Boost list run by bdawes at, gregod at, cpdaniel at, john at