[Top][All Lists]

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

Re: Explicit instanciation of template function

From: jalina
Subject: Re: Explicit instanciation of template function
Date: Wed, 28 Mar 2007 21:57:13 +0200
User-agent: Thunderbird (X11/20070307)

Bernd Strieder a écrit :

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/|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

Thank you. I get the point.

reply via email to

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