考慮這種過於簡單的測試:對C++模板的基本問題
class foo
{
public:
foo(int i);
template< typename T > foo(T);
};
template<> foo::foo(int i) {}
現在,GCC是幸福的編譯時接受這一點,但RVCT編譯器將發出錯誤:
test.cpp", line 11: Error: #792: "foo::foo(int)" is not an entity that can be explicitly specialized
template<> foo::foo(int i) {}
如無問題的「你爲什麼要這麼做」,這是合法的C++(從學術角度?)提前
感謝
只是爲了讓你知道 - 編譯+在VS2010上運行良好 – Schnommus
它適用於我。使用g ++和VC++。 –