This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: template buglet?
- To: <nbecker at fred dot net>
- Subject: Re: template buglet?
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 04 Sep 1998 02:20:38 -0300
- Cc: egcs at cygnus dot com
- References: <E0zEa90-0006L7-00@hns.com>
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