[Issue 11737] Allow optional string value for getopt switches
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 15 12:30:28 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11737
--- Comment #6 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-12-15 12:30:23 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > I think the default argument trick is quite neat. Andrej, would you care to
> > implement it?
>
> I'm sure he'd love to implement it, but delegate and function pointer types
> don't currently keep any information on the name or default value of their
> parameters, meaning that this is currently impossible without declaring a
> function and passing it as an alias template parameter.
getopt is a variadic template, so it's possible to extract this information:
-----
import std.traits;
void getopt(T...)(ref string[] args, T opts)
{
static assert(ParameterDefaultValueTuple!(opts[1])[1] == "bar");
}
void main(string[] args)
{
getopt(args,
"log",
(string option, string value = "bar") { });
}
-----
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list