Bug 4986 – IFTI fails on partial matching with value parameters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-10-04T00:42:00Z
Last change time
2012-05-30T20:45:57Z
Keywords
rejects-valid
Assigned to
nobody
Creator
simen.kjaras
Comments
Comment #0 by simen.kjaras — 2010-10-04T00:42:50Z
The following code fails to deduce the value of m2 in bar:
struct Foo( int n, int m ) {
/// Bugged:
void bar( int m2 )( Foo!( m2, n ) arg ) {}
// Workaround:
void baz( int n2, int m2 )( Foo!( n2, m2 ) arg ) if ( n == n2 ) {}
}
void bug( )( ) {
Foo!(3,2) f;
Foo!(3,3) g;
f.baz( g ); // Works.
f.bar( g ); // Fails.
}
foo.d(14): Error: template foo.Foo!(3,2).Foo.bar(int m2) does not match any func
tion template declaration
foo.d(14): Error: template foo.Foo!(3,2).Foo.bar(int m2) cannot deduce template
function from argument types !()(Foo!(3,3))
Note also that this works for type parameters:
struct Foo( T, U ) {
void bar( V )( Foo!( T, V ) arg ) {}
}
void bug( )( ) {
Foo!(int, float) f;
Foo!(int, string) g;
f.bar( g );
}