我想知道是否可以部分專門化模板方法行爲,以防模板參數之一是某種類型。只專注於模板函數的一部分實現
template<class T>
void Foo(T& parameter)
{
/* some generic - all types - stuff */
If(T is int) // this is pseudo-code, typeinfo? Boost?
{
/* some specific int processing which might not compile with other types */
}
/* again some common stuff */
}
任何建議是值得歡迎的。 感謝
我已經編輯因爲「部分專業化」這個術語的含義與這裏所要求的完全不同。 – bames53