C++ Logo

std-proposals

Advanced search

Re: [std-proposals] I/O Stream Manipulator for Binary Integers (RFC) - Second Draft

From: Javier Estrada <iphone.javier.estrada_at_[hidden]>
Date: Thu, 20 Feb 2025 12:55:42 -0800
Hi Jan,

Good points. I may have to amend the draft (see below).

*(1)* I don't think it would break ABI. The additional ios_base::bin flag
would have to fit within the current bitmask though.
*(2, 3).* Yes, it would have to go through a locale, specifically the
std::num_get and std::num_put facets for I/O, respectively, then modifying
the std::num_get::do_get and std::num_put::do_put protected member
functions). At the end of the day these functions are going through a
flavor and scanf and printf.

Other possibilities, albeit too far fetched, IMO, would be to have
"separators" for representation (e.g., the number 42 in binary nibbles:
0010 1010).

Unfortunately I do not have an implementation but it was clarified that I
wouldn't need one (I imagine if the proposal is doable, but implementers
would be the ones to better opine on complexity and doability).

*References:*
https://en.cppreference.com/w/cpp/locale/num_get/get
https://en.cppreference.com/w/cpp/locale/num_put/put


On Thu, Feb 20, 2025 at 11:41 AM Jan Schultke <janschultke_at_[hidden]>
wrote:

> Is this implementable without breaking ABI? How does it actually work to
> make a stream print binary numbers?
>
> Doesn't that go through locales and whatnot?
>
> On Thu, Feb 20, 2025, 19:11 Javier Estrada via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I've addressed the comments from Chris, Victor and Jonathan. Here's a
>> summary of the changes:
>>
>> - Changed the date to 2025-02-20
>> - Fixed the Audience (thx Victor Zverovich)
>> - Corrected faulty example (thx Chris Ryan)
>> - Eliminated unnecessary *Before* tables (thx Jonathan Wakely)
>> - Added output for examples in Courier New 10 font, non-bold
>> - Added remaining sections
>> - Improved formatting (spacing, alignment, page numbering, page
>> breaks to improve reading flow)
>>
>> I'm attaching the document for your review.
>>
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>

Received on 2025-02-20 20:55:55