How do I pass a type as parameter in this method?
Marc
jckj33 at gmail.com
Mon Dec 18 22:58:58 UTC 2017
Imaginary code:
> int index = FirstOrDefault!(int)(__traits(getAttributes, C.a));
In that case, if the tuple is empty, the value is the int's type
default value.
The method is defined as following:
> template FirstOrDefault(X)(T...) {
> static if(T.length > 0) {
> enum FirstOrDefault = T[0];
> } else {
> enum FirstOrDefault = X.init;
> }
> }
More information about the Digitalmars-d-learn
mailing list