Boost logo

Boost :

Subject: Re: [boost] [property_tree] streaming operators
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-05-13 03:36:25

On Tue, 12 May 2009 17:34:50 -0700, Chris Meyer
<cmeyer1969+boost_at_[hidden]> wrote:
> More on property_tree:
> It would be nice if the default translator did not use the << and >>
> operators by default. In my software, I use << to stream a debugging
> description of an object -- so it is useless for archiving purposes.
> Instead, the detail::translator could define and use
> template <class Ch, class T> inline void
> writeToStream(std::basic_ostream<Ch> &os, const T &value) { os << value;
> template <class Ch, class T> inline void
> readFromStream(std::basic_istream<Ch> &is, T &value) { is >> value; }
> Then clients of the library would have more flexibility in
> implementing the streaming operations by providing specializations of
> these functions.
> (These functions would be used in place of the stream >> and << calls
> in detail::extractor::operator() and it's specializations).
> Is this list the right place for these requests or is there a better
> place to put them so that they get tracked?

The best place to file feature requests is the Boost Trac. However,
requests placed on this list should reach me in general.

I'm not sure about this change. Mostly, I'm worried about the precedent
this sets. If I define my own serialize/unserialize ADL overloads, then
every library that deals with conversion might want to do the same, leading
to a lot of confusing and possibly conflicting ways of converting between
objects and strings. The nice thing about the streaming operators is that
it is one, unified way of doing this thing in C++. The obvious downside is
that it is only one way, and there are, as you observe, several ways in
which one might want to convert objects to strings: debug dump,
serialization form and user-readable form at least.

Hmm ... I wonder if Boost.Convert has something planned for that. If not,
it might be a worthwhile addition. In any case, I hesitate to add something
like this to PropertyTree.


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