|
Boost : |
Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Daniel Wallin (daniel_at_[hidden])
Date: 2009-02-21 03:46:12
Vladimir Batov wrote:
> I personally do not like manipulators. I do not even really know how to
> write them properly. However, they are standard. So, we can say to
> someone -- you wanna do your own formatting? Bring in your manipulator
> and plug it in. Boost.Convert does not need to be changed to accommodate
> that specific request.
>
> How do you do that with Boost.Parameter? How Boost.Convert will know
> about "throw_on_out_of_range_" or any fancy parameter? How Boost.Convert
> will apply/interpret that parameter? If you tell me that the user can
> make Boost.Convert understand that new parameter without modifying
> Boost.Convert, I'll be first to abandon manipulators in their favor.
I haven't followed this thread, so I'm not familiar with this particular
interface, but in general you could compose an ArgumentPack in the
interface function, and pass that down to whatever implementation you
choose. Something like:
BOOST_PARAMETER_NAME(value)
typedef parameters<required<tag::value> > convert_parameters;
template <class U, class T, class A0, ...>
U convert_to(T const& value, A0 const& a0, ...)
{
return convert_impl<U>(convert_parameters(value, a0, ...));
}
The implementation would then just declare a keyword and fetch whatever
parameters they are interested in from the ArgumentPack:
BOOST_PARAMETER_NAME(width)
template <class U, class ArgumentPack>
U convert_impl(ArgumentPack const& args)
{
do_work(
args[_value]
, args[_width | 5]
);
}
-- Daniel Wallin BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk