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?

If I understand what you mean by "is assignable to null", this should do it:

---
enum bool isAssignableNull(T) = is(typeof(null) : T);

// Tests:

immutable string arrayslice = null;
static assert(isAssignableToNull!(immutable string));

void function(int) funptr = null;
static assert(isAssignableToNull!(typeof(funptr)));

int[int] aa = null;
static assert(isAssignableToNull!(int[int]));
---

Reply via email to