Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: David Abrahams (dave_at_[hidden])
Date: 2009-02-23 09:45:04

on Sun Feb 22 2009, "Vladimir Batov" <> wrote:

>>> I am not sure Boost.Parameter can be applied for the Boost.Convert
>>> task in question (although Andrey is really pushing for it
>>> :-)). However, I must say it is a very nifty thing you've come up
>>> with. I am thinking really hard where I might use it. :-)
>> This seems to evade your earlier statement a bit:
>>>> 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.
> Dave, it probably might well appear this way... but I am not really trying to evade
> anything. The thing is that Boost.Parameter is a new thing to me and I have not seen
> much code using it. So, I am still not sure how to plug it into Boost.Convert (sorry
> for using the name I know it's not part of Boost, I just need to refer to it somehow
> quickly).
> Now I understand that Boost.Parameter allows me to call
> convert<string, int>(str, some_user_defined_param = ...);
> As I understand Boost.Convert does not know and does not make use of
> "some_user_defined_param" but takes it in using ArgumentPack. How then does the
> parameter make it to some user-defined formatter? Maybe it is because I am still
> thinking in terms of manipulators -- a user writes his own and plugs it into
> Boost.Convert as
> convert_to<int>(str) >> std::hex;

Well, if the user-defined formatter is not part of the type of the
converter (e.g. encoded in a template parameter) then you will indeed
have some issues because there is a type-erasure boundary to cross. You
could do it (Daniel did it when he extended Boost.Parameter to
interoperate with Python), but I doubt you'd find Boost.Parameter to be
a trivial drop-in solution in that case.

Maybe it could be easily extended to do what you need, though. I don't
know how close your use case comes to the Python use-case. Certainly,
the interface you show above is easy enough to achieve.

Dave Abrahams
BoostPro Computing

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