
Rene Rivera wrote:
Dave, Daniel,
I have a use case which would be nice to support. I have some functions which take some number of flag arguments, akin to:
void foo(const char * name, float value, bool flag1 = false, bool flag2 = false) { std::cout << name << " = " << value << "\n"; }
And I can add the named arg interface, so I can use it as:
foo((value = 5.2f, name = "baz", flag1 = true));
But ideally I'd like the use to look like:
foo((value = 5.2f, name = "baz", flag1));
That is, the presence of the keyword is enough to set the argument to true. Possible?
Not with the current library, but it could very easily be added. Perhaps something like: bool flag1_ = args[flag1.implicit(true) | false]; What do you think? Dave? We could also just have all keywords have an implicit value true, but I think that might cause some problems for users. -- Daniel Wallin