template buglet?

Alexandre Oliva oliva@dcc.unicamp.br
Fri Sep 4 05:03:00 GMT 1998

nbecker  <nbecker@fred.net> writes:

> template<class T> void Go (const T& first, const T& last);

> main() { char buf[256]; Go (buf, buf+strlen(buf)); }

> bug.cc:6: no matching function for call to `Go (char[256], char *)'

> Shouldn't the trivial conversion of char[] -> char* have been tried?

No.  Argument deduction finds that `buf' matches `const T&' for
`T=char[256]', then finds that buf+strlen(buf) matches `const T&' with 
`T=char*'.  Since the two `T's are different, argument deduction fails 
for this template function.

Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
Universidade Estadual de Campinas, SP, Brasil

More information about the Gcc mailing list