【发布时间】:2016-01-07 20:46:31
【问题描述】:
我试着写:
#include <functional>
template<class T, class func = std::less<T>>
class Car {
public:
void check(const T& x, const T& y) {
func(x, y); //.... << problem
}
};
int main() {
Car<int> car;
car.check(6, 6);
return 0;
}
我的意思是它会识别通常的< 和int,但它会显示我标记的位置:
没有匹配函数调用‘std::less::less(const int&, const int&)'
但是,如果我使用自定义 func 创建一个 Car,那么它可以工作...我该如何解决这个问题?
【问题讨论】:
-
编辑参数为
T的