Is there a nice syntax to achieve optional named parameters?
Zenw
zero.error.no.warning at gmail.com
Sat Jan 19 14:26:31 UTC 2019
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
> As an example let's say I have a type 'Window' that represents
> a win32 window. I'd like to be able to construct an instance of
> the type with some optional parameters that default to some
> reasonable settings and create the underlying win32 window.
>
> [...]
how about this
auto With(string code,T)(T value)
{
with(value)
{
mixin(code ~";");
}
return value;
}
auto window = Window().With!q{title = "My window",width =
800,fullscreen = true};
More information about the Digitalmars-d-learn
mailing list