[英]no operator found error with boost read_xml function
我正在嘗試使用read_xml函數將xml文件讀入ptree,如下所示:
read_xml(myFile, myPtree, boost::property_tree::xml_parser::trim_whitespace);
在這里,myFile是std::string
而myPtree是basic_ptree<std::string, std::wstring>.
構建時會出現以下錯誤:
xml_parser_read_rapidxml.hpp(48): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::basic_string<_Elem,_Traits,_Alloc>' (or there is no acceptable conversion)
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
任何可能導致錯誤的指針?
您可能會收到如圖所示的消息,僅僅是因為沒有從std::string
到std::wstring
隱式轉換
在這種情況下,請匹配字符串類型或嘗試調整basic_ptree
專業化程度
由於您是從XML進行解析的,並且XML解析器僅支持一種字符串類型,因此可能 需要使鍵和數據字符串類型相同。
您可以使用與XML解析器匹配的字符串類型,並使用translator_between<std::string, std::wstring>
調用適當的字符集轉換
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.