我的问题是下面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