在std::map中使用TiXmlElement矢量
Using TiXmlElement vector in std::map
在std::map中使用tinyxml API的TiXmlElement向量时,visual studio给出编译时错误。我的代码是。。
#include "tinyxml.h"
#include <vector>
#include <iostream>
#include <map>
using namespace std;
class childCounter
{
public:
childCounter(void);
std::map<string,std::vector<TiXmlElement*>> childrenList;
int count(const TiXmlElement&,const TiXmlAttribute*);
~childCounter(void);
};
int childCounter::count(const TiXmlElement& ele,const TiXmlAttribute* attr)
{
int count = 0;
std::map<string,std::vector<TiXmlElement*>> childList;
std::vector<TiXmlElement*> childVector;
TiXmlElement *ele = new TiXmlElement("ChildOne");
childVector.push_back(ele);
string name = "entry";
childList[name] = childVector;
return count;
}
编译错误是
Error 1 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 2 error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 3 error C2784: 'bool std::operator <(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::move_iterator<_RanIt> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 4 error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 5 error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 6 error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
Error 7 error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
首先,我无法理解出了什么问题,但我知道vector<TiXmlElement*>
有错误。请指引我正确的方向。非常感谢。
缺少#include <string>
它在错误1中:运算符<std::string缺少,因为树特征不可重复数据消除。
Error 1 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' c:program files (x86)microsoft visual studio 11.0vcincludexstddef 180
相关文章:
- 分段故障(堆芯转储)矢量
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 将二维矢量传递给类
- 读取文件并输入到矢量中
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 无法通过空白将文本文件行分隔为矢量
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 正在将csv文件读取为双精度矢量
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何通过 getter 函数删除矢量的元素?
- 如何在C++中将数组转换为矢量指针
- 在C++中将矢量转换为嵌套地图
- C++矢量迭代
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 将矢量<T>转换为矢量<数组<T>>
- 指针或结构的矢量
- 为什么文件名被设置为一个点,而不是在读取矢量中的文件名时
- 用于矢量处理的多个线程
- 反向矢量3
- 在std::map中使用TiXmlElement矢量