Boost logo

Boost :

From: tslettebo_at_[hidden]
Date: 2003-05-06 09:41:02


> From: Markus Werle <numerical.simulation_at_[hidden]>
>
> The feature mentioned in the subject is missing in boost.
> (actually it throws)
> I propose adding something simmilar to the (incomplete) stuff below.
>
> template <typename Source>
> class lexical_stream_common_stuff<bool, Source>

This could be a possibility. Rather than testing for the strings "true" and "false" (which wouldn't respect locale), it may be better to set the ios_base "boolalpha" flag, which reads and writes bool as "true" and "false" (or whatever is set for the locale).

However, the question is that some users may want to read/write "0" and "1", instead.

This has the same problem as other stream configuration, such as setting the number base, etc.

> bool assign_from(const std::string& s)
> {
> if ("true" == s)
> {
> result_ = true;
> return true;
> }
> if ("false" == s)
> {
> result_ = false;
> return true;
> }
> return false;
> }

<snip>

> template<>
> class lexical_stream<bool, const char*>
> : public lexical_stream_common_stuff<bool, const char*>

Regards,

Terje


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