c++ - ptree 迭代器成员未被自动完成识别?

标签 c++ pointers boost autocomplete boost-propertytree

我正在使用 boost 库来解析如下所示的 .ini 文件:

[head]
type1=val1
type2=cal2
...

我的代码是这样的:

#include <iostream>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
using namespace std;

int main()
{
    using boost::property_tree::ptree;

    boost::property_tree::ptree pt;
    boost::property_tree::ini_parser::read_ini("test.ini", pt);

    boost::property_tree::ptree::iterator pos1,pos2;

    for(pos1 = pt.begin(); pos1 != pt.end() ; ++pos1)
    {
        cout << pos1->first << endl;

        for(pos2 = pos1->second.begin() ; pos2 != pos1->second.end() ; ++pos2)
        {
            cout << "    " << pos2->first << "=" << pos2->second.get_value<string>() << endl;
        }
        cout << endl;
    }

    return 0;
}

一切正常,程序输出符合预期,但 eclipse 将所有 pos1 和 pos2“->”标记为错误...intelli sense 不会加载“first”或“second”选项并标记它们的所有用途作为错误...但一切编译...

有什么想法吗??

这是它的样子:

enter image description here

最佳答案

pos1pos2 不是指针,您应该使用 . 而不是 ->

关于c++ - ptree 迭代器成员未被自动完成识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26964701/

相关文章:

c++ - 如何将 std::chrono::minutes 与 boost::json tag_invoke value_from 配合?

c++ - std::shared_ptr<std::vector<double>> 出了什么问题

c++ - 当有人更改虚拟方法时如何保护扩展类

pointers - 如何共享嵌入的结构指针

c - 不兼容的 C 型错误?

c++ - 如何区分AAA :BBB and AAA:BBB:CCC using regular expression?

c++ - 如何确定 C++ 中字符串数组的大小?

c++ - 如何解决 gcc 4.7 和 4.9 之间 std::vector 的不同行为?

c - malloc编译错误: a value of type "int" cannot be used to initialize an entity of type int (*)[30]

c++ - 我正在尝试创建一个 C++ 映射,其中包含 boost 内存映射文件中的 vector 值