[Issue 1715] New: Template specialization checks for equality rather than convertibility
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 4 19:22:17 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1715
Summary: Template specialization checks for equality rather than
convertibility
Product: D
Version: 2.008
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: rejects-valid, spec
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: dhasenan at gmail.com
This is related to #1714: the workaround for 1714 is prevented by this, and
vice versa.
When specializing a template based on the template parameters of its argument,
a check is performed for equality, not convertibility. For every other type
specialization, a check is performed for convertibility rather than equality.
(Equality would be redundant in those situations, and pretty much every
situation.)
Example:
---
class Foo(T){}
class Bar : Foo!(int) {}
template GetFooArg (T : Foo!(U), U) {
alias U GetFooArg;
}
static assert (is (GetFooArg!(Foo!(int)) == int)); // works
static assert (is (GetFooArg!(Bar) == int)); // false
pragma (msg, GetFooArg!(Bar).stringof); // template instance GetFooArg!(Bar)
// does not match any template declaration
---
--
More information about the Digitalmars-d-bugs
mailing list