STL,map 错误:error C2784
来源:互联网 发布:python apt capm模型 编辑:程序博客网 时间:2024/05/03 20:33
一、错误现象:使用map,自定义的类型作为key,出现错误error C2784
error C2784: “bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)”: 未能从“const CDpMysqlConnAttr”为“const std::basic_string<_Elem,_Traits,_Alloc> &”推导 模板 参数
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(243) : 参见“std::operator <”的声明
二、原因:
map中的key默认是以less<>升序对元素排序,也就是说key必须具备operator<对元素排序。
平常我们用的基本上都是基本类型元素作为key,不存在这个问题。
当使用自定义类型或者类,作为key时,如果没有自定义operator<,就会出现该错误。
三、解决办法:
修改作为key的类型,添加operator<。
- STL,map 错误:error C2784
- Error C2784 with std map
- error C2784--------使用map遇到的小问题
- 使用标准模板库map出现错误C2784,C2676
- Error 42 error C2784:
- error C2784处理方法
- VC编译器下如何解决error C2679、error C2676、error C2784、fatal error C1903错误
- fixed: error C2784 from compiling adding an entry to a std::map
- error C2784: 'bool std::operator <(const std::_Tre
- 使用boost库serialize序列化map等STL容器的最常见错误——error C2039
- Error 42 error C2784: 'bool std::operator <(const std::_Tree<_Traits>
- STL-map
- stl -map
- stl map
- STL Map
- STL---map
- STL(MAP)
- STL(map)
- 用斯特拉森算法求解矩阵乘法
- POJ 1503 Integer Inquiry
- CSS中常用的属性_2
- POJ-2761-Feed the dogs
- poj 2449 Remmarguts' Date(A* + dijkstra)
- STL,map 错误:error C2784
- 常见面试题
- LINQ IN js
- JDBC与Java数据库编程
- EBS DG
- CentOS 6.4 编译安装 MySQL-5.6
- CodeForces 146E - Lucky Subsequence DP+扩展欧几里德求逆元
- PHP设计模式-代理模式
- 使用远程调式器追踪源码