Binary Conversion IO
Jonathan Wakely
jwakely.gcc@gmail.com
Fri Sep 13 15:57:00 GMT 2013
On 13 September 2013 16:12, Ed Smith-Rowland wrote:
> Greetings,
>
> I am putting together a tiny proposal for the C++ standard library inspired
> by the C++14 acceptance of binary literals in the core language (which we
> have, and really mostly had since gcc-4.3ish). Before I stuck my neck out I
> wanted to make sure the feature was implementable in libstdc++.
>
> The attached patch adds an enumerator, bin, to ios_base to go along with
> oct, dec, and hex. Similarly, there is a bin manipulator. Additions to
> num_put and num_get write and read binary numbers. As implemented, I have
> it as an extension to C++98 (not isolated by std flags) since we've had
> binary literals available in that version too.
>
> This patch bootstraps and tests clean on x86_64-linux.
>
> 1. Is this a useful/amusing idea (I like it for reading and writing flags)
> suitable for the library. I like the consistency with literals and the rest
> of the library.
I like the idea.
> 2. Can anyone see any showstoppers in this or any other implementation?
I didn't look at the implementation. Paolo's comments are good ones
(although I think G++ always uses int as the underlying type in C++03
and in C++11 when it isn't fixed.)
> 3. Would people possibly accept this as a possibility for inclusion (with
> the hope that it would become standard in future). libstdc++ would then be
> prior art and implementation experience.
Yes, I would be in favour, if it's a conforming extension that doesn't
affect how anything is parsed when the new manipulator is not used.
More information about the Libstdc++
mailing list