[boost] Seeking Endorsement for Charconv

28 views
Skip to first unread message

Matt Borland via Boost

unread,
Sep 21, 2023, 4:26:01 AM9/21/23
to boost@lists.boost.org List, Matt Borland
Hello,

At the beginning of the summer I solicited feedback for an in-progress C++11 implementation of <charconv> for a proposal to Boost. The library is now complete with that feedback incorporated, and I am seeking endorsement. Should the library receive endorsement Chris Kormanyos has volunteered to serve as the review manager.

What is Charconv?

It is a character conversion library that converts a character sequence into a number (from_chars) or converts a number into a character sequence (to_chars). This is similar to strtod and printf with two key differences. First and most important is a roundtrip guarantee. That is a number converted into a character sequence, and then back into a number will be identical to the starting value. Second, you can easily specify an input/output format with a chars_format argument, and also provide a target precision. Lastly, instead of requiring recent compilers (e.g. GCC 11, and MSVC 19.24) and C++17 to get full support for <charconv> you can have it now with GCC 5, Clang 3.7, or MSVC 19.00 and C++11.

What types are supported?

All builtin integers plus __int128 and unsigned __int128. For floating point types all built-in IEEE 754 compliant types to include those provided in C++23’s <stdfloat>, and __float128. A notable example of a non-IEEE 754 compliant built-in type is ibm128 provided on older versions of PowerPC.

How do I use the library?

The repo can be found here: https://github.com/cppalliance/charconv. Since this is a compiled library, directions for use with b2, vcpkg, and conan are provided.

What is the performance like?

I added a table of benchmarks (https://master.charconv.cpp.al/#ref_benchmarks) that compares this implementation to the performance of: STL (printf, strtoX, and <charconv>), Boost.Lexical_Cast, Boost.Spirit, and libdouble-conversion. In summary we meet or exceed the performance of GCC and MSVC <charconv>, and exceed by up to several multiples the performance of all the other libraries. Thanks to Stephan T. Lavavej for providing his benchmarking file in the original discussion.

Why is this not going into Boost.Compat?

The size of this library exceeds the scope of Boost.Compat. Compat is designed for headers that can be implemented in a small amount of code. <latch> with implementation, testing and documentation was ~350 LOC while Charconv is ~29,500.

Please let me know if you have any questions or issues with the library.
Thanks,

Matt Borland

—-
C++ Alliance Staff Engineer

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Dominique Devienne via Boost

unread,
Sep 21, 2023, 8:15:48 AM9/21/23
to bo...@lists.boost.org, Dominique Devienne
On Thu, Sep 21, 2023 at 10:26 AM Matt Borland via Boost <
bo...@lists.boost.org> wrote:

> I added a table of benchmarks (
> https://master.charconv.cpp.al/#ref_benchmarks)

[...] In summary we meet or exceed the performance of GCC and MSVC
> <charconv>,
>

Looking good! Maybe on the to_chars() side, you could add std::to_string
(C++11),
and format/print from FMT lib (C++11 or not less) / std (C++20), to compare
against. --DD

Glen Fernandes via Boost

unread,
Sep 21, 2023, 8:43:23 AM9/21/23
to bo...@lists.boost.org, Glen Fernandes
On Thu, Sep 21, 2023 at 4:25 AM Matt Borland wrote:

> At the beginning of the summer I solicited feedback for an in-progress
> C++11 implementation of <charconv> for a proposal to Boost. The library is
> now complete with that feedback incorporated, and I am seeking endorsement.
> Should the library receive endorsement Chris Kormanyos has volunteered to
> serve as the review manager.
>
>

I endorse it. Aside from users, other Boost libraries are also interested
in using it.

Glen

Matt Borland via Boost

unread,
Sep 21, 2023, 10:44:24 AM9/21/23
to Glen Fernandes, Matt Borland, Andrey Semashev via Boost
>
> I endorse it. Aside from users, other Boost libraries are also interested in using it.
>
> Glen
>

Thanks Glen!

Matt

Matt Borland via Boost

unread,
Sep 21, 2023, 10:50:49 AM9/21/23
to Dominique Devienne, Matt Borland, Andrey Semashev via Boost
>
> Looking good! Maybe on the to_chars() side, you could add std::to_string (C++11),
> and format/print from FMT lib (C++11 or not less) / std (C++20), to compare against. —DD


Good call; I will add those. Thanks.

Matt

Ruben Perez via Boost

unread,
Sep 22, 2023, 12:26:00 PM9/22/23
to bo...@lists.boost.org, Ruben Perez
On Thu, 21 Sept 2023 at 10:26, Matt Borland via Boost
<bo...@lists.boost.org> wrote:
>
> Hello,
>
> At the beginning of the summer I solicited feedback for an in-progress C++11 implementation of <charconv> for a proposal to Boost. The library is now complete with that feedback incorporated, and I am seeking endorsement. Should the library receive endorsement Chris Kormanyos has volunteered to serve as the review manager.
>

I endorse this. I plan on using it to parse MySQL values when using
the text protocol.

Regards,
Ruben.

Vinnie Falco via Boost

unread,
Sep 22, 2023, 12:43:00 PM9/22/23
to bo...@lists.boost.org, Vinnie Falco
On Thu, Sep 21, 2023 at 1:26 AM Matt Borland via Boost
<bo...@lists.boost.org> wrote:
> ...

I endorse this, as it is a perfect fit for Boost: this library is a
straight port of new C++ standard library components to older C++
versions.

However, full disclosure is needed: both Matt Borland and Ruben Perez
are part of The C++ Alliance staff, as well as myself.

Thanks

Ruben Perez via Boost

unread,
Sep 22, 2023, 2:25:35 PM9/22/23
to boost@lists.boost.org List, Ruben Perez
However, full disclosure is needed: both Matt Borland and Ruben Perez
> are part of The C++ Alliance staff, as well as myself.
>

That's true. Apologies for not noting that before.

Regards,
Ruben.
Reply all
Reply to author
Forward
0 new messages