An issue with templates with non-existant symbols
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Aug 21 19:16:38 PDT 2011
void foo(T)(T t) if(is(X == struct)) { }
void main()
{
foo(4);
}
This prints out:
test.d(9): Error: template test.foo(T) if (is(X == struct)) does not
match any function template declaration
test.d(9): Error: template test.foo(T) if (is(X == struct)) cannot
deduce template function
from argument types !()(int)
which is your typical template instantiation error. The real issue is
that the symbol "X" doesn't actually exist.
I've had a template I was refactoring and I've accidentally mistyped
the name of the type, e.g.:
void foo(T)(T r) if (is(T == struct) || is(t == class)) // t should have been T
I was hoping for a better error message here. Can the compiler check
that `is` has an expression with valid symbols in it?
More information about the Digitalmars-d-learn
mailing list