
struct Cord { int x_cord; int y_cord; Cord(int x = 0,int y = 0):x_cord(x),y_cord(y) {} bool operator()(const Cord& cord) const { if (x_cord == cord.x_cord) { return y_cord < cord.y_cord; } return x_cord < cord.x_cord; } };class Cell { };std::map<Cord,Cell> m_layout; 我无法编译上面的代码
error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : Could not deduce template argument for 'const std::basic_string<_Elem,_Alloc> &' from 'const Layout::Cord'
有什么建议吗?
解决方法 你的operator()应该是operator<:bool operator<(const Cord& cord) const { if (x_cord == cord.x_cord) { return y_cord < cord.y_cord; } return x_cord < cord.x_cord; } *** 作符LT;是std :: map用来命令它的键.
总结以上是内存溢出为你收集整理的c – 无法推断出模板参数全部内容,希望文章能够帮你解决c – 无法推断出模板参数所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)