Setting struct as default parameter of a function using struct literal?
Salih Dincer
salihdb at hotmail.com
Mon Sep 11 22:39:00 UTC 2023
On Monday, 11 September 2023 at 22:13:25 UTC, H. S. Teoh wrote:
>
> Because sometimes I want a specific type.
>
it's possible...
```d
alias ST = Options;
void specificType(ST option = ST())
{
if(option)
{
assert(false);
} else
assert(true);
}
void main()
{
specificType(); // No error
specificType(ST.silenceErrorsOn); // assert failure
}
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list