How to test templates for equality?
Rene Zwanenburg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 1 03:43:53 PDT 2014
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.
struct Foo(T)
{
T val;
}
auto createAFoo(T)(string s)
if(is(T == Foo!P, P))
{
return T(s.to!P);
}
More information about the Digitalmars-d-learn
mailing list