|
Boost Users : |
From: John Maddock (john_at_[hidden])
Date: 2007-05-27 07:38:12
I have a few usage questions for the Boost.Parameter library:
1) If I want to have a function called "policy" that's declared using
BOOST_PARAMETER_FUNCTION can I access the types of the arguments both from
within the functions body and for the functions return type:
BOOST_PARAMETER_FUNCTION(
(return-type-computed-from-arguments),
policy,
tag, // 3. namespace of tag types
(optional // optional parameters, with defaults
(domain_error, *, throw_on_error)
)
(deduced
(optional
(precision, *, boost::mpl::int_<53>())
)
)
)
{
// what type are the arguments?
}
I realise I can do this with an argument pack, but then either my users will
have to call the function with an extra set of parenthesis, or I will have
to write a bunch of forwarding functions myself - which itself generates a
"what the is the return type" problem.
>From within the body of the BOOST_PARAMETER_FUNCTION generated function it
appears that I can use the name "Args" to refer to the type of the argument
pack, and maybe in the return type as well? But this isn't documented, so
can I rely on it?
2) All the arguments I want to pass are actually going to end up being used
in meta-programs: for symbolic values, I can make each one a unique enum
type, and use the type of the argument (even though it's actually passed as
a value) to generate my metacode. But I have one optional argument where I
require the value to be an arbitrary compile time constant, the only
interface I can come up with at present is something like:
policy(_digits10 = mpl::int_<10>());
But I'd really like to be able to write:
policy(_digits10 = 12);
and have the "12" converted to mpl::int_<12> "by magic", but I can't think
of any magic that could be applied here... anyone any ideas?
Thanks, John.
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