0
我正在使用boost::units
庫。我的問題是,我要投我的長度矢量成一個雙矢量的CMATH計算:將boost :: units類型轉換爲數字類型
pow(tmpVector.at(cnt),cnt)
CNT是我的循環計數器。如果我在沒有投射的情況下嘗試計算,則將boost::units::length
沒有投射定義的錯誤復原爲double
。
我試圖使用static_cast不工作,並且boost庫的numeric_cast也不起作用。在第二種情況下,我收到以下編譯器錯誤:
e:\testvs12\libraries\thirdparty\boost\boost\numeric\conversion\converter_policies.hpp(187): error C2440: 'static_cast': 'const std::vector<_Ty>' can not convert into 'std::vector<_Ty>'
我什麼也沒有發現在互聯網上 - 我希望你可以幫我
問題1:有沒有使用循環內戰俘的可能性與boost::units
和循環計數器指數?
問題2:如何將boost::units
類型投射到例如雙?
在此先感謝。
您能提供[SSCCE](http://sscce.org)嗎?我假設你沒有「長度」矢量,而是「數量爲」的矢量?你是否嘗試用「米」,「腳」或任何你想使用的單位來劃分? 1米轉換爲雙倍可能是'100.0'(i cm),'39.3701'(英寸)或其他。 –
2013-02-28 14:48:51
這是? tmpVector.at(cnt).value()http://www.boost.org/doc/libs/1_37_0/doc/html/boost/units/quantity.html#id3387713-bb – qPCR4vir 2013-02-28 14:52:36
抱歉,我使用的是數量 –
KaHo
2013-03-01 07:01:11