Type Parameter Deduction
frame
frame86 at live.com
Tue May 10 14:44:06 UTC 2022
On Tuesday, 10 May 2022 at 13:14:20 UTC, Salih Dincer wrote:
> must satisfy the following constraint:
That is your type protection here, a constraint.
Alternatively you can put the constraint in a function and make
it more verbose:
```d
bool isAllowedType(T)()
{
static assert(!is(T == bool), "Nope");
return true;
}
void fun(T = int)(T arg)
if(isAllowedType!T)
{
//..
}
fun(0); // ok
fun(false); // not allowed
```
More information about the Digitalmars-d-learn
mailing list