How to test templates for equality?

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 5 22:33:20 PDT 2014


I have another question about testing if given symbol is instance 
of the given template and geting it's template arguments. I'm 
talking about raw template symbols, but not struct or class 
templates. For case with struct or class template 
std.traits.isInstanceOf is working well. But using *raw* template 
is not possible for it. There is an example.

import std.stdio, std.traits;


template WrapperTemplate(T)
{}

void main()
{
	writeln( isInstanceOf!(WrapperTemplate, WrapperTemplate!(int)) );
}

Because isInstanceOf implemented as *is* expression it expects 
type arguments, but template is not type at all. So this is not 
working. As we have __traits(isSame, ...) we could make such a 
test, but I need to have tuple of template arguments. But I don't 
understand how to get them

template isMyInstanceOf(alias Templ, alias Inst)
{

}



More information about the Digitalmars-d-learn mailing list