This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: template question
- From: Alexander Sieb <sieb at sscd dot de>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 04 Dec 2002 18:23:02 +0100
- Subject: Re: template question
- References: <3DEE2694.FBF94866@physics.uoregon.edu>
Zoltan Nagy wrote:
>
> Hi,
>
> I tried to compile the small code below using the g++-3.2.1 but I got
> the following error message:
>
> test.cc: In member function `void C<TTT>::ff() [with TTT = double]':
> test.cc:31: instantiated from here
> test.cc:20: no matching function for call to `A<double>::f(B<const
> double&, double>&, double&)'
>
> Is it a bug in the compiler or I do something wrong?
>
Seems like T1 is ambiguous.
template<class T1, class T2>
void f(const B<T1,T2>&, T1){}
^^ ^^
|| ||
const double& from b. double from function call
||
\/
What should T1 really be?
In b you define what becomes T1 as const double& while in the member function call
the second parameter is double. T1 cannot be both at the same time.
--
Regards,
Alexander