[英]Cannot get boost header to compile
我想使用Boost庫拆分字符串,但是Visual Studio出現編譯錯誤。
我的代碼具有#include "boost/algorithm/string/split.hpp";
和#include "boost/algorithm/string/classification.hpp";
和我的項目的include目錄包含C:\\Data\\Libraries\\Boost_1.56.0
,其本身包含根boost
與Boost的頭文件的目錄。
然后,我有以下內容:
std::string line = "this,is,a,test";
std::vector<std::string> strings;
boost::algorithm::split(strings, line, boost::is_any_of(','));
但這給了我各種各樣的錯誤,例如:
Error 37 error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c<false,boost::range_const_iterator<char,void>,boost::range_mutable_iterator<char,void>>' C:\Data\Libraries\Boost_1.56.0\boost\range\iterator.hpp 69
有什么幫助嗎?
該消息令人困惑,因為它基本上是發脾氣的模板元編程,但是問題在於boost::is_any_of(',')
無法編譯,因為','
是不能被視為“范圍”的單個字符。
您打算寫:
boost::algorithm::split(strings, line, boost::is_any_of(","));
// ^ ^
您嘗試使用boost::algorithm::split(strings, line, boost::is_any_of(","));
。 這是使用split
功能的另一種解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.