我正在使用 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”选项并标记它们的所有用途作为错误...但一切编译...
有什么想法吗??
这是它的样子:
最佳答案
pos1
和 pos2
不是指针,您应该使用 .
而不是 ->
关于c++ - ptree 迭代器成员未被自动完成识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26964701/