【发布时间】:2013-12-27 01:17:32
【问题描述】:
是实现定义还是标准建议流的默认填充字符?
示例代码:
#include <iostream>
#include <iomanip>
#include <sstream>
int main ()
{
std::stringstream stream;
stream << std::setw( 10 ) << 25 << std::endl;
std::cout << stream.str() << std::endl;
}
与clang++ --stdlib=libstdc++
$ clang++ --stdlib=libstdc++ test.cpp
$ ./a.out | hexdump
0000000 20 20 20 20 20 20 20 20 32 35 0a 0a
000000c
$
与clang++ --stdlib=libc++
$ clang++ --stdlib=libc++ test.cpp
$ ./a.out | hexdump
0000000 ff ff ff ff ff ff ff ff 32 35 0a 0a
000000c
版本
$ clang++ --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
我可以使用 std::setfill(' ') 修复它,但我很想知道它是否是 clang 错误。
【问题讨论】:
-
Fedora 19 上没有“libc++”。你的是什么?
-
@rickhg12hs,我在 Mac 上。不确定linux。
标签: c++ stringstream clang++ libc++ setw