|
Boost Users : |
From: Neil Hunt (boost_at_[hidden])
Date: 2005-12-10 20:26:28
Thanks David (and Joel),
Appreciate the time. That's helped me along the path.
As an aside, I think the docs in
http://www.boost.org/libs/parameter/doc/html/#applying-sfinae-to-the-overload-set
reference a superceded example.
I think "when the name argument is not convertible to const char*." should
be "when the root_vertex argument is not convertible to int." as per the
section above it.
Thanks again,
Neil
"David Abrahams" <dave_at_[hidden]> wrote in message
news:u8xutrqem.fsf_at_boost-consulting.com...
> "Neil Hunt" <boost_at_[hidden]> writes:
>
>> I guess the main thrust of the question is "Does the parameters library
>> support runtime enumeration?"
>
> Not directly, but it seems like something we (sh/c)ould support,
> probably by making ArgumentPacks conforming Fusion sequences so you
> could use boost/spirit/fusion/algorithm/for_each.hpp to enumerate them.
> The problem is that I don't have expertise with Fusion-1 and AFAIK it's
> not
> fully documented. Specifically, I don't know how to make a conforming
> Fusion sequence. Maybe Joel can help. Joel?
>
>> or should I be looking at MPL?
>
> Wouldn't help you, at least not directly. Well, here's one thing you
> could do (ALL_CAPS should be reserved for macros, so I'm going with
> lower_case):
>
> // untested
> BOOST_PARAMETER_KEYWORD(tag, person_window)
> BOOST_PARAMETER_KEYWORD(tag, address_window)
> BOOST_PARAMETER_KEYWORD(tag, employer_window)
>
> typedef mpl::vector<
> tag::person_window, tag::address_window, tag::employer_window
> >
> all_windows;
>
> template <class ArgumentPack, class F>
> struct process_arg
> {
> process_arg(ArgumentPack args, F f) : args(args), f(f) {}
>
> template <class Keyword>
> void operator()(Keyword k) const
> {
> f(k, args[k]);
> }
>
> private:
> ArgumentPack const& args;
> F const& f;
> };
>
> template <class Keywords, class ArgumentPack, class F>
> for_each_arg(ArgumentPack const& args, F const& f)
> {
> mpl::for_each<Keywords>( process_arg<ArgumentPack,F>(args,f) );
> }
>
> Now you can for_each_arg(args, f) where f is some binary function
> you'd like to be applied to each argument. The first parameter is
> the keyword (just in case you need it) and the second one is the
> original argument passed.
>
> This won't cope well with missing default arguments, so it seems to me
> making our ArgumentPacks conforming fusion sequences is really the way
> to go.
>
> --
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net