我有編譯下面的代碼片段升壓綁定功能以參考
int temp;
vector<int> origins;
vector<string> originTokens = OTUtils::tokenize(buffer, ","); // buffer is a char[] array
// original loop
BOOST_FOREACH(string s, originTokens)
{
from_string(temp, s);
origins.push_back(temp);
}
// I'd like to use this to replace the above loop
std::transform(originTokens.begin(), originTokens.end(), origins.begin(), boost::bind<int>(&FromString<int>, boost::ref(temp), _1));
,其中有問題的功能是
// the third parameter should be one of std::hex, std::dec or std::oct
template <class T>
bool FromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) = std::dec)
{
std::istringstream iss(s);
return !(iss >> f >> t).fail();
}
我得到的錯誤是
1>Compiling with Intel(R) C++ 11.0.074 [IA-32]... (Intel C++ Environment)
1>C:\projects\svn\bdk\Source\deps\boost_1_42_0\boost/bind/bind.hpp(303): internal error: assertion failed: copy_default_arg_expr: rout NULL, no error (shared/edgcpfe/il.c, line 13919)
1>
1> return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
1> ^
1>
1>icl: error #10298: problem during post processing of parallel object compilation
問題谷歌正在異常無用,所以我希望有人能提供一些見解。
UPDATE:問題是由@ GF的解決方案回答,但有趣的是,因爲它存儲的轉換操作(失敗/無故障),而不是轉換值本身的結果,最初的功能是不完全正確的。我改變了簽名直接返回轉換後的值,編譯器能夠正確推斷出綁定的類型。
這正是問題所在!謝謝。這個錯誤信息是相當不合理的,不是:) – 2010-04-26 10:07:30
@Jamie:既然這是解決方案,並且你已經接受了它,我認爲你同意這是一個很好的答案,因此應該是upvoted? – 2010-04-26 10:10:53
@Jamie:我知道,Boost.Bind錯誤可能是最不具說明性的錯誤之一,VC cl.exe甚至可能會讓這些錯誤崩潰。 – 2010-04-26 10:17:10