我的問題是下面C++:模板類專業化和類型性狀
template<class T> MyClass
{
MyClass(/* Lots of parameters with no problem */, const T& min = 0, const T& max = std::numeric_limits<T>::max());
set(/* Lots of parameters with no problem */, const T& min = 0, const T& max = std::numeric_limits<T>::max());
/* Lots of function with no problem */
}
我希望我的模板類是兼容std::string
沒有重新實現所有功能。對於std :: string我想要min = ""
和max = ""
。目前,它因爲0而崩潰,例如不能轉換爲字符串。怎麼做 ? (如果我可以只專注於構造函數和主setter,它會很棒)。
兼容你的意思是:如果'T == std :: string'應該可以很好地播放,或者'MyClass'應該是'std :: string'的嵌入替代品? – pmr 2012-07-22 17:55:37