Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/iostream.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ auto operator>>(std::basic_istream<charT, traits>& is, LibType& v)
| Converted to the underlying `uint128_t` and written using its stream support
|===

Standard stream manipulators (`std::hex`, `std::oct`, `std::dec`, `std::setw`, etc.) work as expected.
Standard stream manipulators (`std::hex`, `std::oct`, `std::dec`, `std::showbase`, `std::setw`, etc.) work as expected.

=== Input (`operator>>`)

Expand Down
17 changes: 10 additions & 7 deletions include/boost/safe_numbers/detail/int128/iostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ auto operator<<(std::basic_ostream<charT, traits>& os, const LibIntegerType& v)

auto first {detail::mini_to_chars(buffer, v, base, uppercase)};

if (base == 8)
if (flags & std::ios_base::showbase)
{
*--first = '0';
}
else if (base == 16)
{
*--first = uppercase ? 'X' : 'x';
*--first = '0';
if (base == 8)
{
*--first = '0';
}
else if (base == 16)
{
*--first = uppercase ? 'X' : 'x';
*--first = '0';
}
}

BOOST_SAFE_NUMBERS_DETAIL_INT128_IF_CONSTEXPR (!std::is_same<charT, char>::value)
Expand Down
Loading
Loading