考慮下面的代碼:std :: ofstream == NULL不會編譯爲-std = gnu ++ 11,任何解決方法?
std::ostream file;
if(file == NULL) std::cout << "Failed to open file" << std::endl;
(來自GCC 5.2默認)經過時-std = gnu11,或者僅僅使用
gcc code.cpp -o a.out
它編譯完美。
它失敗-std = GNU + 11,雖然:
no match for ‘operator==’ (operand types are ‘std::ofstream {aka std::basic_ofstream<char>}’ and ‘long int’)`
什麼是最簡單的解決方法嗎?
詳情:
我必須使用std = GNU ++ 11有機會獲得shared_ptr
定義。此外,我的一些代碼會自動生成,修改生成器會產生合理的努力 - 所以我想知道是否有人可以想出更簡單的方法來擺脫這種「缺乏兼容性」。
'如果性病::法院<< 「失敗」(文件!);'' – Pixelchemist
-std = gnu11'是AC標誌 – user3528438
'如果(文件== nullptr)' –