How to check if variable of some type can be of null value?
Alexey
invalid at email.address
Sat Jul 24 19:39:02 UTC 2021
On Saturday, 24 July 2021 at 18:10:07 UTC, Alexey wrote:
> I've tried to use ```typeof(t) is cast(t)null```, but compiler
> exits with error and so this can't be used for checking this
> issue.
>
> The goal I with to achieve by this check - is to use template
> and to assign value to variable basing on it's ability to
> accept null as a value.
>
currently I ended up using ```__traits(compiles, cast(T1)null)```
for this check. but don't know is this really semantically
correct.
More information about the Digitalmars-d-learn
mailing list