
Vladimir.Batov@wrsa.com.au wrote:
So, convert() can take those parameters in. Given we do not know how many parameters there might be I'd suggest we set those parameters with operator(). Like
convert<string, int>(str)(default_ = -1)(throw_ = false)(some_other_parameter_ = ...)
There's no need for that clumsy syntax. The Boost.Parameter keywords already provide the operator, overload, so you can write: convert< string >((param1 = val1, param2 = val2, ...)); ...and so on for as many parameters you like. Note the double parenthesis. The "convert" function here accepts only _one_ argument, which is basically a tuple of references to the argument values with a fancy syntax for retrieving them: template< typename ToT, typename ArgsT > ToT convert(ArgsT const& args) { int p1 = args[param1]; // mandatory string p2 = args[param2 | "ouch"]; // optional } Boost.Parameter also provide macros that allow to declare the "convert" function in order to elide the need of the double parenthesis and to even allow to mix the positional arguments with named ones.