Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-05-03 08:11:18

Vladimir Batov wrote:
> > Gordon Woodhull <gordon <at>> writes:
> > On a similar nice-feature-but-weird-syntax note, let's look
> > at the Using Boost.Convert with Standard Algorithms section,
> > which offers a few ways that you can use convert<T>::from()
> > to create a functor:
> >
> > std::transform(
> > strings.begin(),
> > strings.end(),
> > std::back_inserter(integers),
> > convert<int>::from(string(), -1) >> std::hex);
> > ...
> > I think it would be much more appropriate to provide a
> > Phoenix function object for the purpose, something like
> >
> > std::transform(
> > strings.begin(),
> > strings.end(),
> > std::back_inserter(integers),
> > convert_<int>(_1, -1, std::hex));
> >
> > Sigh of relief. I see what that means immediately, ...
> Apologies for sounding as a broken record but again that
> preference seems quite personal. As a user not familiar with
> Phoenix your variant would not look familiar to me. In order
> to use it I'd need to learn/remember/know additional API --
> convert_, _1, args order. My deployment seems simpler (not
> surprisingly some bias here :-) ) as the user uses the same API
> and does not need to learn more to use 'convert' with
> algorithms.

I didn't mention it before, but I do think Gordon's suggestion is a decent one. Your concern, Vladimir, is valid, but it is reasonably easy to teach enough Phoenix to explain how to use the converter function objects that way and would be helpful to Convert library users in other contexts (not that it is your responsibility to teach them lambdas for other contexts!).

I do realize that generalizing in this way means that users would see whatever template error stack traces mishandling Phoenix would trigger. That's a decided problem with adopting that interface, but in order to use an increasing number of libraries, one must learn a lambda library. Perhaps focusing on enabling lambdas generally, particularly C++1x lambdas, is a better approach than specifically focusing on Phoenix.

Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
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