Boost logo

Boost :

Subject: [boost] [convert] Now with Boost.Parameter interface.
From: Vladimir.Batov_at_[hidden]
Date: 2009-05-04 00:12:10


I've incorporated, uploaded to the Vault and started playing with the
Boost.Parameter-based interface that Andrey Semashev was insisting from
the set-go. And it is definitely growing on me and I like

        int i = convert<int>::from(str, 0)(locale_ = new_locale)(throw_ =
true);

instead of the original

        int i = convert<int>::from(str, 0) >> new_locale >> dothrow;

I think people generally did not like locales and dothrow behaving like
manipulators.

The more I use the Boost.Parameter-based interface the more I am inclined
to push it further and apply it to manipulators as well. I.e.

        int i = convert<int>::from(str)(radix_ = 16);

instead of the original direct handling of std manipulators.

        int i = convert<int>::from(str) >> std::hex;

Something, again, Andrey was advocating from the start. Now it feels like
allowing io-stream manipulators exposes too much implementation detail and
raises some unwarranted expectations.

That raises a few questions that I am hoping people could help me with:

1. Both interfaces (for locale and dothrow) are currently supported:

#1 int i = convert<int>::from(str, 0)(locale_ = new_locale)(throw_
= true);
#2 int i = convert<int>::from(str, 0) >> new_locale >> dothrow;

Should I remove #1?

2. Both interfaces

#1 int i = convert<int>::from(str, 0) >> std::hex;
#2 int i = convert<int>::from(str, 0)(radix_ = 16);

are currently supported. Should I move away from direct manipulator
support and remove #1?

3. I only managed to figure out how to supply only one Boost.Parameter at
a time like

        int i = convert<int>::from(str, 0)(locale_ = new_locale)(throw_ =
true);

I understand how to achieve

        int i = convert<int>::from(str, 0)((locale_ = new_locale, throw_ =
true));

(with double quotes) but do not want to go there as it looks somewhat
unorthodox. I cannot figure out how to achieve the following

        int i = convert<int>::from(str, 0)(locale_ = new_locale, throw_ =
true);

(a list inside single quotes). I remember Andrey mentioning I could do
that with a Boost.Parameter macro but I admit of not being bright enough
to figure it out by myself. Any help would be greatly appreciated.

Thanks,
Vladimir.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk