On Tuesday, 22 May 2018 at 11:08:13 UTC, Jonathan M Davis wrote:
That's basically what dxml does except that it takes advantage
of the fact that each member is a different type (because each
is a differnt instance of std.typecons.Flag) so that it can
have a variadic function which takes any of the arguments in
any order. e.g.
enum config = makeConfig(SkipComments.yes, SplitOnEmpty.yes);
auto range = parseXML!config(xml);
or
auto range = parseXML!(makeConfig(SkipComments.yes,
SplitOnEmpty.yes))(xml);
I don't see how that is any better.
* It requires implementing `makeConfig`
* It requires using std.typecons.Flag which I think is an ugly
hack due to the lack of named arguments
* It only supports boolean types
By using a regular struct it's also possible to specify named
arguments and in any order:
struct Options
{
bool foo;
int value;
bool bar;
string value2;
}
Options options = { value2: "asd", bar: true, foo: false };
--
/Jacob Carlborg