Boost logo

Boost :

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


On Friday, February 27, 2009 1:55 PM
Emil Dotchevski wrote:
> On Fri, Feb 27, 2009 at 5:40 AM, Stewart, Robert
> <Robert.Stewart_at_[hidden]> wrote:
> >>
> >> What's wrong with the following call syntax:
> >>
> >> boost::convert<target>( source const & [,arg1,arg2,...] )
> >>
> >> that is, the caller provides the target type for the
> >> conversion, then
> >> the first argument is considered the source (deduced
> >> automatically),
> >> and the rest of the arguments configure the conversion.
> >
> > That only works if the argument types and number are known
> > ahead of time. The Boost.Parameter approach allows for open
> > ended extension -- for good or ill.
>
> I don't understand. The overload-based approach can also be extended
> -- by providing more overloads, user-defined or generic overloads
> given by the convert framework itself.

Each of your arg1, arg2, ...argN must have a type or be deduced by the compiler in a function template. In order to use them as formatting options, the function [template] must understand which parameters(s) map to the needed formatting option(s), while ignoring the rest. Thus, the order, purpose, etc. must be known beforehand. Each new, custom formatting option extends the set introduced by *all* other custom formatting options. That is untenable.

With the Boost.Parameters approach, the formatting options are gathered into, conceptually, a dictionary which is accessed by keys. A given convert function template must know about the keys it deems important and can use them to access the desired options.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk