zoukankan      html  css  js  c++  java
  • could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

    VS2008, 写一个简单的demo的时候出现了这个: 

    1>------ Build started: Project: GetExportTable, Configuration: Release Win32 ------
    1>Compiling...
    1>main.cpp
    1>e: zcodegetexporttablegetexporttableGetExportTable.h(61) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1> E:TzSoftVS2008VCincludestdio.h(306) : see declaration of 'scanf'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludextree(1466) : see declaration of 'std::operator <'
    1> E:TzSoftVS2008VCincludefunctional(142) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
    1> with
    1> [
    1> _Ty=std::string
    1> ]
    1> E:TzSoftVS2008VCincludemap(68) : see reference to class template instantiation 'std::less<_Ty>' being compiled
    1> with
    1> [
    1> _Ty=std::string
    1> ]
    1> E:TzSoftVS2008VCincludextree(22) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
    1> with
    1> [
    1> _Kty=std::string,
    1> _Ty=int,
    1> _Pr=std::less<std::string>,
    1> _Alloc=std::allocator<std::pair<const std::string,int>>,
    1> _Mfl=false
    1> ]
    1> E:TzSoftVS2008VCincludextree(63) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
    1> with
    1> [
    1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
    1> ]
    1> E:TzSoftVS2008VCincludextree(89) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
    1> with
    1> [
    1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
    1> ]
    1> E:TzSoftVS2008VCincludextree(107) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
    1> with
    1> [
    1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
    1> ]
    1> E:TzSoftVS2008VCincludemap(78) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
    1> with
    1> [
    1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
    1> ]
    1> .main.cpp(65) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
    1> with
    1> [
    1> _Kty=std::string,
    1> _Ty=int
    1> ]
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludextree(1466) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludextree(1466) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludextree(1466) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludevector(1320) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludevector(1320) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludevector(1320) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludevector(1320) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
    1> E:TzSoftVS2008VCincludelist(1310) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
    1> E:TzSoftVS2008VCincludelist(1310) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
    1> E:TzSoftVS2008VCincludelist(1310) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
    1> E:TzSoftVS2008VCincludelist(1310) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2236) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2236) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2236) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2236) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2046) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2046) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2046) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludexutility(2046) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludeutility(84) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludeutility(84) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludeutility(84) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludeutility(84) : see declaration of 'std::operator <'
    1>E:TzSoftVS2008VCincludefunctional(143) : error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>Build log was saved at "file://e:TzCodeGetExportTableGetExportTableReleaseBuildLog.htm"
    1>GetExportTable - 25 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    开始把注意力集中在

    1>E:TzSoftVS2008VCincludefunctional(143) : 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'
    1> E:TzSoftVS2008VCincludextree(1466) : see declaration of 'std::operator <'

    还以为是std::string没了 operator< 

    又怀疑是否是模板实例化的时候有啥别的问题(const, 类型转化之类的). 

    最后在网上搜了一下原来是没有#include <string>

    但是为啥没报string是未定义标识符? 

    猜测可能是在哪个头文件里面声明了class string, 但是没有实现. 于是会找不到 string 的operator< .

    具体原因有待进一步考证 

  • 相关阅读:
    hdu 1232 最小生成树
    hdu 1260 dp
    hdu 1385 最短路径按字典数输出
    hdu 1541 树状数组
    hdu 1544 求字符串回文
    hdu 1728
    hdu 1754 树状数组求最大值
    hdu 1892 二维树状数组
    hdu 2082 母函数
    循环
  • 原文地址:https://www.cnblogs.com/HGtz2222/p/3336737.html
Copyright © 2011-2022 走看看