歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 關於boost::property_tree在VS2010下編譯的問題

關於boost::property_tree在VS2010下編譯的問題

日期:2017/3/1 10:40:43   编辑:Linux編程

前些時,某編譯測試了mongodb的c++客戶端接口庫,該庫依賴於boost_1.42,因此某的mongo NoSQL庫的訪問接口也用了boost的這個版本。這個版本的boost::property_tree卻在VS2010下編譯不過,具體症狀為:

  1. 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>::* '
  2. with
  3. [
  4. _Ty1=const std::string,
  5. _Ty2=boost::property_tree::basic_ptree<std::string,std::string>
  6. ]
  7. and
  8. [
  9. _Elem=char,
  10. _Traits=std::char_traits<char>,
  11. _Ax=std::allocator<char>,
  12. _Ty1=const std::string,
  13. _Ty2=boost::property_tree::basic_ptree<std::string,std::string>
  14. ]
  15. 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十分方便。

Copyright © Linux教程網 All Rights Reserved