[PATCH] C++17 P0067R5 std::to_chars and std::from_chars (partial)
Jakub Jelinek
jakub@redhat.com
Mon Oct 2 19:53:00 GMT 2017
On Mon, Oct 02, 2017 at 03:13:17PM +0100, Jonathan Wakely wrote:
> This adds the integral overloads of std::to_chars and std::from_chars,
> including the changes made by P0682R0. Support for floating point types
> is absent.
>
> This uses a number of suggestions from Lars (thanks!) but I might have
> missed some of his ideas and so could be missing some potential
> optimizations.
>
> An earlier version of the patch was posted in
> https://gcc.gnu.org/ml/libstdc++/2017-04/msg00025.html
>
> * include/Makefile.am: Add new <charconv> header.
> * include/Makefile.in: Regenerate.
> * include/precompiled/stdc++.h: Include <charconv>.
> * include/std/charconv: New file.
> (to_chars_result, to_chars, from_chars_result, from_chars): Define.
> * testsuite/20_util/from_chars/1.cc: New test.
> * testsuite/20_util/from_chars/1_neg.cc: New test.
> * testsuite/20_util/from_chars/2.cc: New test.
> * testsuite/20_util/from_chars/requirements.cc: New test.
> * testsuite/20_util/to_chars/1.cc: New test.
> * testsuite/20_util/to_chars/1_neg.cc: New test.
> * testsuite/20_util/to_chars/2.cc: New test.
> * testsuite/20_util/to_chars/requirements.cc: New test.
>
> Tested powerpc64le-linux, committed to trunk.
This fails on 32-bit targets, there are too many closing >s if
__int128_t is missing.
Either of the attached patches fixes this, which one do you prefer (or do
you want yet another formatting)?
Jakub
-------------- next part --------------
2017-10-02 Jakub Jelinek <jakub@redhat.com>
* include/std/charconv (__unsigned_least_t): Fix number of closing >s for
!_GLIBCXX_USE_INT128.
--- libstdc++-v3/include/std/charconv.jj 2017-10-02 18:51:40.000000000 +0200
+++ libstdc++-v3/include/std/charconv 2017-10-02 21:37:16.085823955 +0200
@@ -81,7 +81,11 @@ namespace __detail
#if _GLIBCXX_USE_INT128
conditional_t<(sizeof(_Tp) <= sizeof(__int128)), unsigned __int128,
#endif
- void>>>>;
+ void
+#if _GLIBCXX_USE_INT128
+ >
+#endif
+ >>>;
// Generic implementation for arbitrary bases.
template<typename _Tp>
-------------- next part --------------
2017-10-02 Jakub Jelinek <jakub@redhat.com>
* include/std/charconv (__unsigned_least_t): Fix number of closing >s for
!_GLIBCXX_USE_INT128.
--- libstdc++-v3/include/std/charconv.jj 2017-10-02 18:51:40.000000000 +0200
+++ libstdc++-v3/include/std/charconv 2017-10-02 21:44:02.416799016 +0200
@@ -80,8 +80,10 @@ namespace __detail
conditional_t<(sizeof(_Tp) <= sizeof(long long)), unsigned long long,
#if _GLIBCXX_USE_INT128
conditional_t<(sizeof(_Tp) <= sizeof(__int128)), unsigned __int128,
-#endif
void>>>>;
+#else
+ void>>>;
+#endif
// Generic implementation for arbitrary bases.
template<typename _Tp>
More information about the Libstdc++
mailing list