Trait for "can be instantiated"?

Ben Jones fake at fake.fake
Tue May 10 03:52:52 UTC 2022


On Monday, 9 May 2022 at 21:58:59 UTC, Ali Çehreli wrote:
> On 5/9/22 14:24, Ben Jones wrote:
>
> > Is there a trait that can tell if you
> > can initialize a variable of a certain type?
>
> Not answering that question but the 'is' expression seems to 
> work in this case:
>
>     static if(is (T)) {
>          T value;
>     }
>
>   https://dlang.org/spec/expression.html#IsExpression
>
> Ali

Using is(T) instead of isType!T also appears to be true for the 
un-instantiate-able enum.  Was your point just that I could 
replace isType!T with is(T)?


More information about the Digitalmars-d-learn mailing list