Template constraint on alias template parameter.
jmh530
john.michael.hall at gmail.com
Thu Aug 6 16:01:35 UTC 2020
The code below compiles, but I want to put an additional
constraint on the `test` function is only called with a Foo
struct.
I tried things like is(T == Foo) and is(T : Foo), but those don't
work. However, something like is(T!int : Foo!int) works, but
is(T!U == Foo!U, U) doesn't. Any idea why is(T!U == Foo!U, U)
doesn't work?
struct Foo(T)
{
T x;
}
void test(alias T)()
if (__traits(isTemplate, T))
{
import std.stdio: writeln;
writeln("there");
}
void main()
{
test!Foo();
}
More information about the Digitalmars-d-learn
mailing list