[libcxx-commits] [libcxx] [libc++] Optimize num_put integral functions (PR #120859)
Nico Weber via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 11 10:55:51 PDT 2025
nico wrote:
Did you end up adding a release notes entry?
I reduced the `int256` thing mentioned above to
```
#include <algorithm>
#include <sstream>
#include <utility>
#include <gtest/gtest.h>
struct MyType {};
std::ostream& operator<<(std::ostream& o, const MyType& b) {
return o << 0;
}
TEST(Int256, OStream) {
struct {
std::ios_base::fmtflags flags;
const char* rep;
} cases[] = {
// showbase does nothing on zero
{ std::ios::dec | std::ios::showbase, "0"},
{ std::ios::oct | std::ios::showbase, "0"},
{ std::ios::hex | std::ios::showbase, "0"},
};
for (size_t i = 0; i < ABSL_ARRAYSIZE(cases); ++i) {
std::ostringstream os;
os.flags(cases[i].flags);
MyType type;
os << type;
EXPECT_EQ(cases[i].rep, os.str());
}
}
```
That used to pass; now it outputs `0`, `00`, and `0x0` instead. (I.e. showbase on `0` used to not add a prefix and now it does.)
I'm guessing that's also intentional?
https://github.com/llvm/llvm-project/pull/120859
More information about the libcxx-commits
mailing list