Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-02-27 08:30:34

On Thursday, February 26, 2009 4:44 PM
Emil Dotchevski wrote:
> On Thu, Feb 26, 2009 at 12:07 PM, Stewart, Robert
> <Robert.Stewart_at_[hidden]> wrote:
> > On Thursday, February 26, 2009 3:03 PM
> > Emil Dotchevski wrote:
> >>
> >> If I'm the maintainer of class uuid and I am asked to provide a
> >> to-string conversion, you'll find it very difficult to convince me
> >> that it makes sense to replace this:
> >>
> >> #include <string>
> >>
> >> namespace user {
> >> class uuid;
> >> std::string to_string( uuid const & );
> >> }
> >>
> >> with all of this:
> >>
[snip long alternative]
> >
> > That's a bit unfair, don't you think? I know that you only
> > wish to support std::string conversions, but the more complex
> > machinery shown in the latter variant supports open ended
> > formatting options and various target types.
> Let's assume that converting to all kinds of target types with
> open-ended formatting options in a single convert<> function is
> desirable. Within that assumption, we need to provide reasonable
> support for the case when the conversion of an uuid object to
> std::string requires no parameters.

I see your point and I think it is reasonable.

> You can do this by requiring uuid.hpp to include all kinds of headers
> and template goodness, learn your complex argument forwarding
> framework -or- you can design your framework in a way that allows it
> to bind simple function declarations or even member functions and
> expose them through the generic convert<> interface.

The framework uses IOStreams to do its work. I believe the conversion functionality for the uuid type is captured via:

   namespace user
      class uuid;

      template <class Stream>
      Stream &
      operator <<(Stream &, uuid const &);

For interoperability with IOStreams, uuid will probably offer that function anyway, so there's no additional burden.

> I prefer the latter. Do you really find this unfair?

I prefer the IOStreams version.

If the conversion can support formatting, then it must look in the Stream object's iword/pword facility to find the additional information to guide it. It might also be that there could be support for a specialized convert() overload or function template that takes a Boost.Parameter argument pack to deliver the additional formatting information. If that's the case, the uuid author only does the heavy lifting when the additional formatting is desirable.

Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

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