This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: template buglet?


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
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]