Re: How to test templates for equality?

2014-07-06 Thread Uranuz via Digitalmars-d-learn
In this particular case, the only solution I know of is an awful hack: using .stringof and __traits(identifier, x) and then parse the strings: "Name!(int, double[string])" and "Name(T, U[V], U, V)" and then the fun begins: in the general case, you must then equate the arguments lists (recursi

Re: How to test templates for equality?

2014-07-06 Thread Philippe Sigaud via Digitalmars-d-learn
Seeing his example, the OP wants a solution that works even for templates: template Test1(T) {} pragma(msg, instanceArgsOf!(Test1, Test1!int)); which fails because Test1!int is not a type (std.traits.isInstanceOf fails also, for the same reason). And is(symbol == Name!Args, Args...) does not wor

Re: How to test templates for equality?

2014-07-06 Thread Ali Çehreli via Digitalmars-d-learn
On 07/05/2014 10:33 PM, Uranuz wrote: I have another question about testing if given symbol is instance of the given template and geting it's template arguments. Applying Rene Zwanenburg's message... It is not complete because integral template parameters don't work yet. import std.typetuple

Re: How to test templates for equality?

2014-07-05 Thread Uranuz via Digitalmars-d-learn
template isMyInstanceOf(alias Templ, alias Inst) { alias Args = ???; //I don't have idea how to get it enum bool isMyInstanceOf = __traits(isSame, Templ!(Args), Inst); } Do you have any idea how to solve this? May be standad library could be improved with such type of test for templat

Re: How to test templates for equality?

2014-07-05 Thread Uranuz via Digitalmars-d-learn
Suddenly posted. I don't know why it's happened)) template isMyInstanceOf(alias Templ, alias Inst) { alias Args = ???; //I don't have idea how to get it enum bool isMyInstanceOf = __traits(isSame, Templ!(Args), Inst); } Do you have any idea how to solve this? May be standad library c

Re: How to test templates for equality?

2014-07-05 Thread Uranuz via Digitalmars-d-learn
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*

Re: How to test templates for equality?

2014-07-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:58:19 UTC, Uranuz wrote: Thanks for quick response. I really forget to look into language __traits statement. Another option: enum isFoo(T) = is(T == Foo!P, P...); By using such an is-expression you get the parameters Foo was instantiated with as an added bonus.

Re: How to test templates for equality?

2014-06-30 Thread Uranuz via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:51:17 UTC, Peter Alexander wrote: template Foo(T...) {} template Bar(T...) {} template isFoo(alias F) { enum isFoo = __traits(isSame, F, Foo); } pragma(msg, isFoo!Foo); // true pragma(msg, isFoo!Bar); // false Thanks for quick response. I really forget to

Re: How to test templates for equality?

2014-06-30 Thread Peter Alexander via Digitalmars-d-learn
template Foo(T...) {} template Bar(T...) {} template isFoo(alias F) { enum isFoo = __traits(isSame, F, Foo); } pragma(msg, isFoo!Foo); // true pragma(msg, isFoo!Bar); // false

Re: How to test templates for equality?

2014-06-30 Thread Uranuz via Digitalmars-d-learn
I suddenly posted it for somehow. But I hope idea is clear. How could I test if symbol is equal to some concrete template. I tried these examples: template isFoo(alias F) { enum bool isFoo = is( F == Foo ); } template isFoo(alias F) { enum bool isFoo = F == Foo; } Could you advise som

How to test templates for equality?

2014-06-30 Thread Uranuz via Digitalmars-d-learn
I have a question. How could I know if some alias or template parameter is some template symbol. I want to not that I want to know that symbol is template symbol itself but not instance of template (std.traits.isInstanceOf give answer for that question). I'll give some example template Foo(T