【问题标题】:tinyXml2 causes error C2675 on build - xtree.cstinyXml2 在构建时导致错误 C2675 - xtree.cs
【发布时间】:2017-02-04 22:50:10
【问题描述】:

在构建使用 tinyXml2 的项目后,我收到以下三个错误。错误显示在附图中。有问题的代码可以在 tinyXml2 的 xtree.cs 文件中找到,这里:

template<class _Iter>
    void insert(_Iter _First, _Iter _Last)
    {   // insert [_First, _Last) one at a time
    _DEBUG_RANGE(_First, _Last);
    for (; _First != _Last; ++_First)
        {   // insert element as lvalue
        const value_type& _Val = *_First;
        insert(end(), _Val);
        }
    }

tinyXml2_Errors

我正在使用(并且必须继续使用)VS2010

什么可能导致这些错误?

1) 错误 C2675:一元 '++':'std::string' 未定义此运算符或转换为预定义运算符可接受的类型

2) 错误 C2100:非法间接

3) 错误 C2440: 'initializing': 无法从 'std::string' 转换为 'const std::pair<_ty1> &'

编辑:包含错误

【问题讨论】:

    标签: c++ visual-studio-2010 tinyxml2


    【解决方案1】:

    我评论了类(和标题)中的所有内容并添加了代码,直到收到错误为止。这个失败实际上不是由于 tinyXml2 - 它是在映射中插入字符串失败。

    对于将来遇到此问题的任何其他人,这是有问题的函数,它不会在 Visual Studio 中生成曲折的红线。

        map<string, string> createMap(CNintendoItem ni)
        {
        map<string, string> xmlNodeToValue;
    
        //ItemName is a string constant. ni.Name is a string returned from a class
        xmlNodeToValue.insert(ItemName, ni.Name);//name of the item
    
        ...//several more insertions
    
        return xmlNodeToValue;
    }
    

    解决此问题的一种方法是使用以下方法为新键分配值:

    xmlNodeToValue[ItemName] = ni.Name;//name of the item
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-20
      • 2011-09-14
      • 2017-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多