Eg:

template aliasOf(T) {
    enum aliasOf(alias a) = is(typeof(a) == T);
}

The use case for this is for std.meta.allSatisfy for variadic args, i.e.

template T(values...) if (allSatisfy!(aliasOf!string, values) { ... }

But how do you call that template otherwise?

I've tries:

* aliasOf!int!"string" // multiple ! arguments are not allowed
* (aliasOf!int)!"string" // error c-style cast
* aliasOf!int.aliasOf!"string" // template isAliasOf(alias a) does not have property 'isAliasOf

I can work around this by:

template typeOf(T) {
    enum isAliasedBy(alias a) = is(typeof(a) == T);
}

and then do:

template T(values...) if (allSatisfy!(typeOf!string.isAliasedBy, values) { ... }

But I like the readability of the former better if there's a way to achieve it?

Cheers
- Ali

Reply via email to