Is there a difference between the following approaches?
// approach 1
namespace std
{
template<>
void swap<Foo>(Foo& x, Foo& y) // note the <Foo>
{
x.swap(y);
}
}
// approach 2
namespace std
{
template<>
void swap(Foo& x, Foo& y)
{
x.swap(y);
}
}
I stumpled upon this when I tried to specialize swap for my own string type and noticed that swap<::string>
doesn't work, but for a completely different reason :)