is(T t == U!n, U, int n)
Simen Kjærås
simen.kjaras at gmail.com
Wed Jun 13 10:34:48 UTC 2018
On Wednesday, 13 June 2018 at 09:41:45 UTC, Luís Marques wrote:
> ...why can't I generalize it to match U!n, for some U, int n?
>
> template X(T)
> {
> static if(is(T t == U!n, U, int n))
U needs to be alias U, since S is not a type, but a template.
This works:
template X(T)
{
static if(is(T t == U!n, alias U, int n))
{
static if(n == 0)
alias X = AliasSeq!();
else
alias X = U!0;
}
else
{
static assert(0);
}
}
class S(int n) { }
pragma(msg, X!(S!3));
Also, you might want to consider the Learn forum for these kinds
of questions in the future. :)
--
Simen
More information about the Digitalmars-d
mailing list