How do you call an eponymous template that has a secondary template arg?
aliak
something at something.com
Sun Mar 11 12:05:56 UTC 2018
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
More information about the Digitalmars-d-learn
mailing list