David Abrahams wrote:
"Johan Nilsson"
writes:
[snip]
It should be possible (I think) to define a BOOST_PARAMETER_CTOR macro that generate the ctor overloads and forwards to a setter method instead of the other way around.
It won't be general enough to initialize constant or reference members.
That's true, but for my current purposes it's good enough. I've defined my own <foo>_PARAMETER_CTOR macro which takes care of it by delegation. Ideally a BOOST_PARAMETER_CTOR macro should handle initialization of const and reference members automagically, but if restrictions were stated clearly in the docs I'd find an imperfect inclusion better than no one at all. I personally very rarely use constant/reference class members, but understand your concerns. Perhaps a BOOST_PARAMETER_RESTRICTED_CTOR (or similarly ugly-named) macro could be included in the library? Otherwise, maybe mentioning something about constructors in the faq would be a good idea? Also, should the BOOST_PARAMETER_MEMFUN macro be documented?
2. Is there a way of detecting whether an argument was passed using position or name?
Nope.
Ok.
Or, even better, is there a way of restricting the arguments to only be passed by name using the parameters specification?
Nope. Why do you want to do that?
I'd like to make sure that users have absolutely (well, almost) no
possibility of using arguments incorrectly. Consider the following (does not
compile):
---
#include
{}; BOOST_PARAMETER_FUN(int, wrap_foo, 0, 4, wrap_foo_args) { return foo(p[index_p|-1], p[low_limit_p|0], p[high_limit_p|255], p[buffer_size_p|1]); } int foo_with_fixed_high_and_buffer_size(int ndx, int low) { return wrap_foo(low, ndx, high_limit_p = 1, buffer_size_p = 10); // ouch ... } --- [snip remaining] // Johan