ambiguous call to overloaded template function

R

Ruki

I want to overload function to swap two others types, for example,
type<T>, T* and so on,
but I can't compile the following code at VC 6.0.

The compiler says :
error C2667: 'swap' : none of 2 overload have a best conversion
error C2668: 'swap' : ambiguous call to overloaded function
-------------------------------------------------------------------------------------------------------------
template < typename T >
void swap(T &lhs, T &rhs)
{
// do some thing
}

template < typename T >
void swap(T *lhs, T *rhs)
{
// do some thing
}

template < typename T >
struct type{};

template < typename T >
void swap(type<T> &lhs, type<T> &rhs)
{
// do some thing
}
int main()
{
int *p1,*p2;
type<int> t1, t2;
swap(t1, t2);
swap(p1, p2);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top