以下方法有什麼區別嗎?專用功能模板的語法
// 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);
}
}
我stumpled在這個當我試圖專注交換爲自己的字符串類型,發現swap<::string>
不起作用,但對於一個完全不同的原因:)
什麼類型':: string' name? – Potatoswatter 2010-04-30 22:55:35
我自己的玩具字符串類型在全局命名空間中。 – fredoverflow 2010-04-30 23:59:42