Getting template parameters by its name
Yui Hosaka
hos at hos.ac
Fri Jan 11 04:59:50 UTC 2019
I want to do something like this:
----
template S(T) {
}
void main() {
pragma(msg, S!(int).T); // Error: no property `T` for type
`void`
}
----
Using alias, it is possible to get T by another name:
----
template S(T) {
alias t = T;
}
void main() {
pragma(msg, S!(int).t);
}
----
But the same identifier cannot be used:
----
template S(T) {
alias T = T; // Error: `alias T = T;` cannot alias itself, use
a qualified name to create an overload set
}
void main() {
pragma(msg, S!(int).T);
}
----
Is there any nice way that `S!(int).T` works?
More information about the Digitalmars-d-learn
mailing list