关于boost::property_tree在VS2010下编译的问题

前些时,某编译测试了mongodb的c++客户端接口库,该库依赖于boost_1.42,因此某的mongo NoSQL库的访问接口也用了boost的这个版本。这个版本的boost::property_tree却在VS2010下编译不过,具体症状为:

c:\boost\boost\property_tree\detail\ptree_implementation.hpp:30: 错误:C2440: 'specialization' : cannot convert from 'const std::string std::_Pair_base<_Ty1,_Ty2>::* ' to 'const std::basic_string<_Elem,_Traits,_Ax> std::pair<_Ty1,_Ty2>::* '
with
[
    _Ty1=const std::string,
    _Ty2=boost::property_tree::basic_ptree<std::string,std::string>
]
and
[
    _Elem=char,
    _Traits=std::char_traits<char>,
    _Ax=std::allocator<char>,
    _Ty1=const std::string,
    _Ty2=boost::property_tree::basic_ptree<std::string,std::string>
]
Standard conversion from pointer-to-member of base to pointer-to-member of derived is not applied for template arguments

而某的其它模块使用了boost_1.47.0版本,在VS2010下编译boost::property_tree却没有任何问题。因此,解决办法很自然就是使用boost_1.47.0的那个版本,替换一下即可。

稍微说一下boost::property_tree,某主要使用其中的json_parser(此外还有ini xml 等parser)。mongodb使用的是bson,与json非常相近,并且有一个十分方便的函数fromjson可从json转换到bson。boost::property_tree的json_parser用于创建及解析json格式数据,配合操作访问mongodb十分方便。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章