Date: Thu, 20 Feb 2025 21:16:09 +0000
On Thu, 20 Feb 2025 at 20:56, Javier Estrada via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> 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.
>
>
They're not implemented using scanf or printf. Note that the spec for
num_put::do_put says "determine the characters that would be printed by
printf" i.e. the C++ library replicates the behaviour of printf without
necessarily calling printf.
A derived std::num_put defined in the program won't know what to do if you
ask it to print in binary format, so every user-defined num_put facet would
need to be updated to support this (or the program would have to accept
that the bin flag might be ignored).
> 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
>>>
>> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
> 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.
>
>
They're not implemented using scanf or printf. Note that the spec for
num_put::do_put says "determine the characters that would be printed by
printf" i.e. the C++ library replicates the behaviour of printf without
necessarily calling printf.
A derived std::num_put defined in the program won't know what to do if you
ask it to print in binary format, so every user-defined num_put facet would
need to be updated to support this (or the program would have to accept
that the bin flag might be ignored).
> 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
>>>
>> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-02-20 21:16:26