cost 97 ms
boost 詞法轉換錯誤:將字符串轉換為 unsigned long long 時,源類型值無法解釋為目標

[英]boost bad lexical cast: source type value could not be interpreted as target when converting a string to unsigned long long

我在wandbox.org上編譯的以下代碼段導致了以下錯誤。 我不明白為什么我收到錯誤。 啟動 prog.cc:在函數 'int main()' 中:prog.cc:11:15: 警告:未使用的變量 'result' [-Wunused-variable] 11 | Ulonglong r ...

Lexical_cast引發異常

[英]Lexical_cast throws exception

在將字符串轉換為int8_t的過程中boost :: lexical_cast引發異常,但是int32_t-規范。 int8_t有什么問題? ...

什么時候boost :: lexical_cast到std :: string失敗了?

[英]When does boost::lexical_cast to std::string fail?

我正在編寫單元測試並嘗試覆蓋所有代碼。 我的代碼中有這樣的東西: 我正在閱讀這些文檔 ,但無法找到有關何時boost::lexical_cast到std::string可以拋出異常的任何信息。 你能幫幫我嗎? 如果不可能,我會簡單地刪除這個try-catch。 如果可 ...

模板化的get方法可從表中檢索混合數據類型

[英]Templated get method to retrieve mixed data types from table

我知道標題沒有意義,找不到更好的名稱。 我需要為SQlite表提供C ++接口,在其中可以存儲鍵/值/類型配置設置,例如 為了簡單和靈活起見,數據模型將值托管為字符串,但提供一列以保留原始數據類型。 這就是我想象的一個客戶端調用這種c ++接口的方式。 這就是我想象的 ...

scanf,printf和boost :: lexical_cast本質上是不安全的嗎?

[英]Are scanf, printf and boost::lexical_cast fundamentally unsafe?

我最近遇到了一個將十進制字符串(例如"10.057" )轉換為double 。 這個問題是與全球應用的語言環境,使用boost::lexical_cast和一些歐洲語言環境中使用的事實,為小數點。 該家族中的scanf , printf和其他功能存在相同的問題。 我很想聽聽其他人如 ...

為什么lexical_cast要求operator >>在匹配的命名空間中?

[英]Why does lexical_cast require the operator>> to be in a matching namespace?

這是一個測試用例: Boost拒絕轉換,聲稱沒有匹配的operator>> : ( 演示 ) 但是,當我在命名空間N聲明/定義operator>>時,代碼的工作方式與廣告一樣。 為什么? 為什么查找會失敗? ...

boost::lexical_cast 與 boost::units::quantity 不再編譯

[英]boost::lexical_cast with boost::units::quantity does not compile any more

我在解析通過 boost_program_options 獲取的值到 boost::units 數量的代碼有問題。 它曾經工作得很好,現在,在新的設置上,不再工作了。 模糊的錯誤消息暗示了 boost::lexical_cast 的問題,它似乎被 program_options 使用。 一個最小的 ...

為 boost::property_maps 中的枚舉專門化 boost::lexical_cast

[英]specializing boost::lexical_cast for enums in boost::property_maps

我正在嘗試使用在其捆綁的頂點屬性中具有enum的boost::graph 。 當我嘗試將捆綁屬性用於 boost::dynamic_property 時,問題就開始了。 看起來我無法為 boost::lexical_cast 獲得正確的模板特化來識別類型。 如果我嘗試直接編寫enum ,則一切正 ...

捕獲boost :: bad_lexical_cast時,我可以訪問要投射的字符串/令牌嗎?

[英]When catching a boost::bad_lexical_cast, can I access the string/token which was to be cast?

我正在運行的代碼可能會在投射一系列令牌時拋出boost:bad_lexical_cast但我無法進入代碼並將令牌“拋在一邊”,因此我可以弄清楚實際投放失敗了。 boost:bad_lexical_cast是否boost:bad_lexical_cast讓您訪問它嘗試以某種方式進行轉換的字符 ...

轉換字符串令牌流時如何避免重復的istringstream構建

[英]How to avoid repeated istringstream construction when converting stream of string tokens

我(打算)使用此答案中的代碼從CSV中讀取內容。 本質上,我得到了一個在連續的,字符之間的字符串的迭代器; 但是我不想將它們放在字符串向量中,而是想將這些字符串解析為(任意)類型T的元素,該元素來自模板參數。 所以... 我可以使用一個istringstream`(例如在這里建議) ...

對於小於雙倍范圍的值,啟用boost :: lexical_cast會超出范圍錯誤

[英]Enable boost::lexical_cast to throw out of range error for values smaller than double range

boost::lexical_cast會為大於double的最大值的值拋出錯誤。 但是對於小於最小值的數字,它會默默地將其設為零。 如何為以后的情況啟用超出范圍的錯誤(即如果一個數字小於2.22507e-308,那么解析器應該拋出一些錯誤)? ...

具有負數的lexical_cast在不同的計算機上的行為不同

[英]lexical_cast with negative number behaves differently on different machines

我在兩個不同的設備上具有相同版本的Boost,但是對於 文檔指出它應該給我INT_MAX(2的補碼翻轉),但是在一台機器上我會拋出異常,而在另一台機器上我會得到INT_MAX。 ...

提高:: lexical_cast的 <signed char> 不能處理負數?

[英]boost::lexical_cast<signed char> cannot handle negative numbers?

這個簡短的C ++程序表現得讓我感到困惑: 使用g++ 5.2.1和boost-1.58.0 ,我得到: 在拋出'boost :: exception_detail :: clone_impl&gt;'的實例后調用終止what():錯誤的詞法強制轉換:源類型值無法解釋為目標 ...

歧義運算符&gt;&gt;在Mac OSX上使用Boost 1.59 lexical_cast

[英]Ambiguous operator>> using Boost 1.59 lexical_cast on Mac OSX

在使用帶有重載輸入/輸出運算符的自定義類使用boost :: lexical強制轉換時,在Max OSX上進行編譯時,我得到的模棱兩可的重載運算符&gt;&gt;。 在這種情況下,Boost 1.59是使用Macports安裝的。 下面是一個獨立的示例,說明了錯誤和所需的結果: #in ...

fedora 20上的boost / lexical_cast

[英]boost/lexical_cast on fedora 20

我正在嘗試編譯並運行C ++程序,其中在fedora 20中安裝了boost-devel 1.50 boost/lexical_cast.hpp ,在其中安裝了boost-devel 1.50 我得到的如下: 在另一台裝有ubuntu 10.04和boost 1.40操作系統的PC ...


 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM