D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1714 - Type specialization in IsExpression should work for templated types
Summary: Type specialization in IsExpression should work for templated types
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2007-12-04 15:33 UTC by Neia Neutuladh
Modified: 2015-06-09 01:14 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Neia Neutuladh 2007-12-04 15:33:40 UTC
class Bar (T) {}
static if (is (Bar!(int) T == T!(U), U)) // should evaluate to true, U == int, T == ? probably Bar!(int)
{}

class Foo : Bar!(int) {}
static if (is (Foo T == T!(U), U)) // should evaluate to false
{}
static if (is (Foo T : T!(U), U)) // should evaluate to true, U == int
{}


Currently, you can do similar stuff in template specializations, but it should be extended to IsExpressions, according to the documentation. So it's implied, anyway.
Comment 1 Don 2010-11-08 04:47:03 UTC
The syntax was slightly wrong. Using correct syntax, as shown below, it failed on all versions of DMD up to and including 2.048. It was fixed in 2.049.

class Bar (T) {}
static if (is (Bar!(int) T == W!(U), alias W, U))
{
    pragma(msg, W.stringof);
    pragma(msg, U.stringof);
} else static assert(0);

class Foo : Bar!(int) {}
static if (is (Foo T == W!(U), alias W, U))
{
    static assert(0);
}

static if (is (Foo T2 : W2!(U2), alias W2, U2))
{
    pragma(msg, W2.stringof);
    pragma(msg, U2.stringof);
} else static assert(0);
Comment 2 Simen Kjaeraas 2010-11-08 05:22:16 UTC
See also bug 3608, which is definitely related, but concerns variadic template lists.