【发布时间】:2015-11-17 00:24:16
【问题描述】:
以下代码在 mac osx 上使用 clang 打印 0。它在其他任何地方打印 5 (clang, gcc)
#include <iostream>
#include <sstream>
int main() {
std::istringstream iss("5C3");
double n;
iss >> n;
std::cout << n << std::endl;
return 0;
}
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
当我使用 int 时,它会按预期打印 5..
operator>> of std::istringstream 是如何工作的,为什么会这样?有没有办法让它以一致的方式工作? (即摘录5)
【问题讨论】:
标签: c++ macos c++11 clang clang++