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);
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);