[Parameter] Positional arg after named arg

Hi, With the parameter library is there any way to stop misuse as in; func(/*a = */1,b = 2); Fine, a is positional, b is named. func(a = 1,2); Happily compiles but probably isn't what was intended, the default value is used for the second parameter. Should positional arguments be allowed to occur after named arguments? Perusing the Parameter library docs I can't see any mention as to what should happen here. Regards, Richard. (using VC8.0 & cvs head)

Richard Crossley wrote:
Hi,
With the parameter library is there any way to stop misuse as in;
func(/*a = */1,b = 2); Fine, a is positional, b is named.
func(a = 1,2);
Happily compiles but probably isn't what was intended, the default value is used for the second parameter.
Are you sure? func(a = 1, 2) is the equivalent of func(1,2) or func(a = 1, b = 2)
Should positional arguments be allowed to occur after named arguments?
We considered not allowing it, but came to the conclusion that there would be little point in doing so since the binding rules are pretty simple; positional argument are bound by their absolute position. We do recommend that named parameters trail positional ones though. -- Daniel Wallin

Solved. Completely down to operator error.
FWIW. Some brackets had become misplaced.
BOOST_PARAMETER_KEYWORD(tag,a)
BOOST_PARAMETER_KEYWORD(tag,b)
struct parameters : boost::parameter::parameters<
boost::parameter::required
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Richard Crossley Sent: 31 May 2006 11:24 To: boost-users@lists.boost.org Subject: [Boost-users] [Parameter] Positional arg after named arg
Hi,
With the parameter library is there any way to stop misuse as in;
func(/*a = */1,b = 2); Fine, a is positional, b is named.
func(a = 1,2);
Happily compiles but probably isn't what was intended, the default value is used for the second parameter. Should positional arguments be allowed to occur after named arguments?
Perusing the Parameter library docs I can't see any mention as to what should happen here.
Regards,
Richard.
(using VC8.0 & cvs head)
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Daniel Wallin
-
Richard Crossley