From: Patrick Palka Date: Mon, 25 Sep 2023 18:48:26 +0000 (-0400) Subject: libstdc++: Shorten integer std::to/from_chars symbol names X-Git-Tag: basepoints/gcc-15~5885 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf3c19903a801063551e43bdc2b8b7ea2f69b781;p=thirdparty%2Fgcc.git libstdc++: Shorten integer std::to/from_chars symbol names For std::to_chars: The constrained alias __integer_to_chars_result_type seems unnecessary ever since r10-3080-g28f0075742ed58 got rid of the only public overload which used it. Now only non-public overloads are constrained by it (through their return type) and these non-public overloads aren't used in a SFINAE context, so the constraints have no observable effect. So this patch gets rid of this alias, which greatly shortens the symbol names of the affected functions (since the expanded alias is quite large). For std::from_chars: We can't get rid of the corresponding alias because its constrains the public integer std::from_chars overload. But we can avoid having the constraint bloat the mangled name by instead encoding it as a defaulted template parameter. We use the non-type parameter form enable_if_t<..., int> = 0 instead of the type parameter form typename = enable_if_t<...> because the type form can be bypassed by giving an explicit template argument for the type parameter, e.g. 'std::from_chars(...)', so the non-type form seems like the more robust choice. In passing, use __is_standard_integer in the constraint. libstdc++-v3/ChangeLog: * include/std/charconv (__detail::__integer_to_chars_result_type): Remove. (__detail::__to_chars_16): Use to_chars_result as return type. (__detail::__to_chars_10): Likewise. (__detail::__to_chars_8): Likewise. (__detail::__to_chars_2): Likewise. (__detail::__to_chars_i): Likewise. (__detail::__integer_from_chars_result_type): Inline the constraint into ... (from_chars): ... here. Use __is_standard_integer in the constraint. Encode constraint as a defaulted non-type template parameter instead of within the return type. --- diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv index 7edb6ade3d42..cb428fe6d3b7 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -85,17 +85,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __detail { - template - using __integer_to_chars_result_type - = enable_if_t<__or_<__is_signed_integer<_Tp>, - __is_unsigned_integer<_Tp>, -#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__ - is_same<_Tp, signed __int128>, - is_same<_Tp, unsigned __int128>, -#endif - is_same>>::value, - to_chars_result>; - // Pick an unsigned type of suitable size. This is used to reduce the // number of specializations of __to_chars_len, __to_chars etc. that // get instantiated. For example, to_chars and to_chars @@ -168,7 +157,7 @@ namespace __detail } template - constexpr __integer_to_chars_result_type<_Tp> + constexpr to_chars_result __to_chars_16(char* __first, char* __last, _Tp __val) noexcept { static_assert(__integer_to_chars_is_unsigned<_Tp>, "implementation bug"); @@ -214,7 +203,7 @@ namespace __detail } template - constexpr __integer_to_chars_result_type<_Tp> + constexpr to_chars_result __to_chars_10(char* __first, char* __last, _Tp __val) noexcept { static_assert(__integer_to_chars_is_unsigned<_Tp>, "implementation bug"); @@ -237,7 +226,7 @@ namespace __detail } template - constexpr __integer_to_chars_result_type<_Tp> + constexpr to_chars_result __to_chars_8(char* __first, char* __last, _Tp __val) noexcept { static_assert(__integer_to_chars_is_unsigned<_Tp>, "implementation bug"); @@ -290,7 +279,7 @@ namespace __detail } template - constexpr __integer_to_chars_result_type<_Tp> + constexpr to_chars_result __to_chars_2(char* __first, char* __last, _Tp __val) noexcept { static_assert(__integer_to_chars_is_unsigned<_Tp>, "implementation bug"); @@ -326,7 +315,7 @@ namespace __detail } // namespace __detail template - constexpr __detail::__integer_to_chars_result_type<_Tp> + constexpr to_chars_result __to_chars_i(char* __first, char* __last, _Tp __value, int __base = 10) { __glibcxx_assert(2 <= __base && __base <= 36); @@ -553,18 +542,13 @@ namespace __detail return true; } - template - using __integer_from_chars_result_type - = enable_if_t<__or_<__is_signed_integer<_Tp>, - __is_unsigned_integer<_Tp>, - is_same>>::value, - from_chars_result>; - } // namespace __detail /// std::from_chars for integral types. - template - _GLIBCXX23_CONSTEXPR __detail::__integer_from_chars_result_type<_Tp> + template, + is_same>>::value, int> = 0> + _GLIBCXX23_CONSTEXPR from_chars_result from_chars(const char* __first, const char* __last, _Tp& __value, int __base = 10) {