Listing 1: Specializations

template<class T>
swap(T &, T &)

template<class T, class A>
swap(vector<T, A> &, vector<T, A> &)

template<>
void swap<int>(int &, int &)

//
// call swap(char &, char &)
// implicitly specialized from
// first overload
//
char c1, c2;
swap(c1, c2);

//
// call swap(int &, int &)
// explicitly specialized from
// first overload
//
int i1, i2;
swap(i1, i2);

//
// call swap(std::vector<int, A> &,
//           std::vector<int, A> &)
// implicitly specialized from
// second overload
//
typedef std::allocator<int> A;
std::vector<int, A> v1, v2;
swap(v1, v2);
— End of Listing —