2014-09-08 4 views
0

std :: map에서 tinyxml API의 TiXmlElement 벡터를 사용하는 동안 Visual Studio에서 컴파일 타임 오류가 발생합니다. 내 코드는 ...std :: map에서 TiXmlElement 벡터 사용

#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; 
} 

컴파일 오류가 나는 무엇이 잘못되었는지 파악 드릴 수 없습니다 우선,하지만 난 그 오류가 vector<TiXmlElement*> 함께 알고 온

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.0\vc\include\xstddef 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.0\vc\include\xstddef 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.0\vc\include\xstddef 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.0\vc\include\xstddef 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.0\vc\include\xstddef 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.0\vc\include\xstddef 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.0\vc\include\xstddef 180 

이다. 제게 올바른 방향을 안내해주세요. 고맙습니다.

+1

관련 없음 : 'string'이 네임 스페이스 한정이 아니고'std :: vector '가 아닌 이유를 이해하지 못했습니다. – WhozCraig

답변

2

#include <string>

누락이 오류 1의 : 트리 특성이 deducable 아니기 때문에 운영자 <는, 표준 : : 문자열이 없습니다.

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.0\vc\include\xstddef 180 
+0

너무 빨라 .. :). 그것으로 오류가 해결되었습니다. – Raki

관련 문제