How do you call an eponymous template that has a secondary template arg?
aliak
something at something.com
Mon Mar 12 15:46:15 UTC 2018
On Monday, 12 March 2018 at 04:15:23 UTC, Simen Kjærås wrote:
> Yeah, that's a little hole in the grammar, but there are ways:
>
> // Declare an alias:
> alias aliasOfInt = aliasOf!int;
>
> // And use that:
> assert(!aliasOfInt!string);
>
>
> Or use std.meta.Instantiate:
>
> assert(!Instantiate!(aliasOf!int, string));
>
> --
> Simen
Noice! Did not know about instantiate.
Btw: I just tried this and it worked, to my surprise!:
template aliasOf(T) {
auto aliasOf(U)(U) { return is(U == T); }
enum aliasOf(alias a) = aliasOf!int(a);
}
void main() {
writeln(aliasOf!int(3)); // works
writeln(allSatisfy!(aliasOf!int, 3)); // works
}
More information about the Digitalmars-d-learn
mailing list