help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Explicit instanciation of template function


From: Bernd Strieder
Subject: Re: Explicit instanciation of template function
Date: Wed, 28 Mar 2007 11:27:56 +0200
User-agent: KNode/0.10.4

Hello,

jalina wrote:
> template<typename T>
> void my_swap(T& v1, T& v2)

>      char i = 'a';
>      char j = 'b';

>      my_swap(i, j);
>      my_swap<int>(i, j); // <=  /tmp/tmpl.cc|22| error: no matching
> function for call to ?my_swap(char&, char&)?

There is no conversion from "char" to "int&". "char" to "char&" is
possible, "char" to "const int&" is possible via a temporary, but
my_swap needs "int&".

> Is it a known behavior ? bug in my compiler (gcc 4.1.2, ubuntu) ? ...
> ?

No C++ compiler may accept it.

Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]