On Friday, 26 February 2021 at 05:45:39 UTC, Nathan S. wrote:
On Friday, 26 February 2021 at 05:34:26 UTC, Paul Backus wrote:
On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote:
I started with:
enum isAssignableNull(T) = is(T : Object) || isPointer(T);
but how do I cover all cases?
Something like this should work:
enum isAssignableNull(T) = __traits(compiles, (T t) => t =
null);
`isAssignableNull!(immutable void*)` is true with his
definition but false with yours. Of course you are correct that
you cannot assign to an immutable pointer.
yep, it must be true for pointers too. Thank you all guys.
is(typeof(null) : T) works like a charm