diff --git a/libcxx/include/__charconv/tables.h b/libcxx/include/__charconv/tables.h --- a/libcxx/include/__charconv/tables.h +++ b/libcxx/include/__charconv/tables.h @@ -23,6 +23,7 @@ namespace __itoa { +# if _LIBCPP_STD_VER < 17 /// Contains the charconv helper tables. /// /// In C++17 these could be inline constexpr variable, but libc++ supports @@ -35,130 +36,171 @@ static const uint32_t __pow10_32[10]; static const uint64_t __pow10_64[20]; -# ifndef _LIBCPP_HAS_NO_INT128 +# ifndef _LIBCPP_HAS_NO_INT128 // TODO FMT Reduce the number of entries in this table. static const __uint128_t __pow10_128[40]; - static const int __pow10_128_offset = 0; -# endif +# endif static const char __digits_base_10[200]; }; +# endif +# if _LIBCPP_STD_VER < 17 template -const char __table<_Tp>::__base_2_lut[64] = { - '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1', - '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0', - '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'}; +const char __table<_Tp>::__base_2_lut[64] +# else +inline constexpr char __base_2_lut[64] +# endif + = {'0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1', + '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0', + '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'}; +# if _LIBCPP_STD_VER < 17 template -const char __table<_Tp>::__base_8_lut[128] = { - '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2', - '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', - '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0', - '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3', - '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', - '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'}; - +const char __table<_Tp>::__base_8_lut[128] +# else +inline constexpr char __base_8_lut[128] +# endif + = {'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2', + '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', + '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0', + '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3', + '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', + '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'}; + +# if _LIBCPP_STD_VER < 17 template -const char __table<_Tp>::__base_16_lut[512] = { - '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0', - 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', - '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2', - '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd', - '2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', - '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', - '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', '5', - '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b', - '5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', - '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2', - '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7', - 'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', - '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', - '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0', - 'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a', - 'c', 'a', 'd', 'a', 'e', 'a', 'f', 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7', - 'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c', - '3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e', - 'c', 'f', 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd', - 'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5', - 'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f', - '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', - 'f', 'd', 'f', 'e', 'f', 'f'}; - +const char __table<_Tp>::__base_16_lut[512] +# else +inline constexpr char __base_16_lut[512] +# endif + = {'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', + '0', 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', + '1', '6', '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', + '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', + '2', 'c', '2', 'd', '2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', + '3', '7', '3', '8', '3', '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', + '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', + '4', 'd', '4', 'e', '4', 'f', '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', + '5', '8', '5', '9', '5', 'a', '5', 'b', '5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', + '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', + '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', + '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7', 'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', + '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', + '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9', + '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0', 'a', '1', 'a', '2', 'a', '3', 'a', '4', + 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a', 'c', 'a', 'd', 'a', 'e', 'a', 'f', + 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7', 'b', '8', 'b', '9', 'b', 'a', + 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c', '3', 'c', '4', 'c', '5', + 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e', 'c', 'f', 'd', '0', + 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd', 'a', 'd', 'b', + 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5', 'e', '6', + 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f', '1', + 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', + 'f', 'd', 'f', 'e', 'f', 'f'}; + +# if _LIBCPP_STD_VER < 17 template -const uint32_t __table<_Tp>::__pow10_32[10] = { - UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000), - UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)}; - +const uint32_t __table<_Tp>::__pow10_32[10] +# else +inline constexpr uint32_t __pow10_32[10] +# endif + = {UINT32_C(0), + UINT32_C(10), + UINT32_C(100), + UINT32_C(1000), + UINT32_C(10000), + UINT32_C(100000), + UINT32_C(1000000), + UINT32_C(10000000), + UINT32_C(100000000), + UINT32_C(1000000000)}; + +# if _LIBCPP_STD_VER < 17 template -const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0), - UINT64_C(10), - UINT64_C(100), - UINT64_C(1000), - UINT64_C(10000), - UINT64_C(100000), - UINT64_C(1000000), - UINT64_C(10000000), - UINT64_C(100000000), - UINT64_C(1000000000), - UINT64_C(10000000000), - UINT64_C(100000000000), - UINT64_C(1000000000000), - UINT64_C(10000000000000), - UINT64_C(100000000000000), - UINT64_C(1000000000000000), - UINT64_C(10000000000000000), - UINT64_C(100000000000000000), - UINT64_C(1000000000000000000), - UINT64_C(10000000000000000000)}; +const uint64_t __table<_Tp>::__pow10_64[20] +# else +inline constexpr uint64_t __pow10_64[20] +# endif + = {UINT64_C(0), + UINT64_C(10), + UINT64_C(100), + UINT64_C(1000), + UINT64_C(10000), + UINT64_C(100000), + UINT64_C(1000000), + UINT64_C(10000000), + UINT64_C(100000000), + UINT64_C(1000000000), + UINT64_C(10000000000), + UINT64_C(100000000000), + UINT64_C(1000000000000), + UINT64_C(10000000000000), + UINT64_C(100000000000000), + UINT64_C(1000000000000000), + UINT64_C(10000000000000000), + UINT64_C(100000000000000000), + UINT64_C(1000000000000000000), + UINT64_C(10000000000000000000)}; # ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_STD_VER < 17 +const int __pow10_128_offset = 0; template -const __uint128_t __table<_Tp>::__pow10_128[40] = { - UINT64_C(0), - UINT64_C(10), - UINT64_C(100), - UINT64_C(1000), - UINT64_C(10000), - UINT64_C(100000), - UINT64_C(1000000), - UINT64_C(10000000), - UINT64_C(100000000), - UINT64_C(1000000000), - UINT64_C(10000000000), - UINT64_C(100000000000), - UINT64_C(1000000000000), - UINT64_C(10000000000000), - UINT64_C(100000000000000), - UINT64_C(1000000000000000), - UINT64_C(10000000000000000), - UINT64_C(100000000000000000), - UINT64_C(1000000000000000000), - UINT64_C(10000000000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000), - __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000), - (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10}; +const __uint128_t __table<_Tp>::__pow10_128[40] +# else +inline constexpr int __pow10_128_offset = 0; +inline constexpr __uint128_t __pow10_128[40] +# endif + = {UINT64_C(0), + UINT64_C(10), + UINT64_C(100), + UINT64_C(1000), + UINT64_C(10000), + UINT64_C(100000), + UINT64_C(1000000), + UINT64_C(10000000), + UINT64_C(100000000), + UINT64_C(1000000000), + UINT64_C(10000000000), + UINT64_C(100000000000), + UINT64_C(1000000000000), + UINT64_C(10000000000000), + UINT64_C(100000000000000), + UINT64_C(1000000000000000), + UINT64_C(10000000000000000), + UINT64_C(100000000000000000), + UINT64_C(1000000000000000000), + UINT64_C(10000000000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000), + __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000), + (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10}; # endif +# if _LIBCPP_STD_VER < 17 template -const char __table<_Tp>::__digits_base_10[200] = { - // clang-format off +const char __table<_Tp>::__digits_base_10[200] +# else +inline constexpr char __digits_base_10[200] +# endif + = { + // clang-format off '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', @@ -171,6 +213,32 @@ '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'}; // clang-format on +# if _LIBCPP_STD_VER > 14 +# define _LIBCPP_ITOA_TABLE_BASE_2 __base_2_lut +# define _LIBCPP_ITOA_TABLE_BASE_8 __base_8_lut +# define _LIBCPP_ITOA_TABLE_BASE_16 __base_16_lut + +# define _LIBCPP_ITOA_TABLE_POW10_32 __pow10_32 +# define _LIBCPP_ITOA_TABLE_POW10_64 __pow10_64 +# ifndef _LIBCPP_HAS_NO_INT128 +# define _LIBCPP_ITOA_TABLE_POW10_128 __pow10_128 +# endif + +# define _LIBCPP_ITOA_TABLE_DIGITS_BASE_10 __digits_base_10 +# else +# define _LIBCPP_ITOA_TABLE_BASE_2 __table<>::__base_2_lut +# define _LIBCPP_ITOA_TABLE_BASE_8 __table<>::__base_8_lut +# define _LIBCPP_ITOA_TABLE_BASE_16 __table<>::__base_16_lut + +# define _LIBCPP_ITOA_TABLE_POW10_32 __table<>::__pow10_32 +# define _LIBCPP_ITOA_TABLE_POW10_64 __table<>::__pow10_64 +# ifndef _LIBCPP_HAS_NO_INT128 +# define _LIBCPP_ITOA_TABLE_POW10_128 __table<>::__pow10_128 +# endif + +# define _LIBCPP_ITOA_TABLE_DIGITS_BASE_10 __table<>::__digits_base_10 +# endif + } // namespace __itoa #endif // _LIBCPP_CXX03_LANG diff --git a/libcxx/include/__charconv/to_chars_base_10.h b/libcxx/include/__charconv/to_chars_base_10.h --- a/libcxx/include/__charconv/to_chars_base_10.h +++ b/libcxx/include/__charconv/to_chars_base_10.h @@ -13,6 +13,7 @@ #include <__algorithm/copy_n.h> #include <__charconv/tables.h> #include <__config> +#include <__memory/addressof.h> #include #include @@ -35,7 +36,7 @@ } _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept { - return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first); + return std::copy_n(&_LIBCPP_ITOA_TABLE_DIGITS_BASE_10[__value * 2], 2, __first); } _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept { @@ -130,8 +131,8 @@ /// range that can be used. However the range is sufficient for /// \ref __base_10_u128. _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept { - _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds"); - return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset]; + _LIBCPP_ASSERT(__exp >= __pow10_128_offset, "Index out of bounds"); + return _LIBCPP_ITOA_TABLE_POW10_128[__exp - __pow10_128_offset]; } _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept { diff --git a/libcxx/include/charconv b/libcxx/include/charconv --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -88,6 +88,7 @@ #include <__config> #include <__debug> #include <__errc> +#include <__memory/addressof.h> #include <__type_traits/make_32_64_or_128_bit.h> #include <__utility/unreachable.h> #include // for log2f @@ -137,7 +138,7 @@ static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { auto __t = (32 - std::__libcpp_clz(static_cast(__v | 1))) * 1233 >> 12; - return __t - (__v < __table<>::__pow10_32[__t]) + 1; + return __t - (__v < _LIBCPP_ITOA_TABLE_POW10_32[__t]) + 1; } static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) @@ -145,7 +146,7 @@ return __itoa::__base_10_u32(__p, __v); } - static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; } + static _LIBCPP_HIDE_FROM_ABI decltype(_LIBCPP_ITOA_TABLE_POW10_32)& __pow() { return _LIBCPP_ITOA_TABLE_POW10_32; } }; template @@ -163,12 +164,12 @@ /// zero. static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { auto __t = (64 - std::__libcpp_clz(static_cast(__v | 1))) * 1233 >> 12; - return __t - (__v < __table<>::__pow10_64[__t]) + 1; + return __t - (__v < _LIBCPP_ITOA_TABLE_POW10_64[__t]) + 1; } static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); } - static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; } + static _LIBCPP_HIDE_FROM_ABI decltype(_LIBCPP_ITOA_TABLE_POW10_64)& __pow() { return _LIBCPP_ITOA_TABLE_POW10_64; } }; @@ -190,16 +191,16 @@ _LIBCPP_ASSERT(__v > numeric_limits::max(), "The optimizations for this algorithm fail when this isn't true."); // There's always a bit set in the upper 64-bits. auto __t = (128 - std::__libcpp_clz(static_cast(__v >> 64))) * 1233 >> 12; - _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds"); + _LIBCPP_ASSERT(__t >= __pow10_128_offset, "Index out of bounds"); // __t is adjusted since the lookup table misses the lower entries. - return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1; + return __t - (__v < _LIBCPP_ITOA_TABLE_POW10_128[__t - __pow10_128_offset]) + 1; } static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); } // TODO FMT This pow function should get an index. // By moving this to its own header it can be reused by the pow function in to_chars_base_10. - static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; } + static _LIBCPP_HIDE_FROM_ABI decltype(_LIBCPP_ITOA_TABLE_POW10_128)& __pow() { return _LIBCPP_ITOA_TABLE_POW10_128; } }; #endif @@ -383,7 +384,7 @@ unsigned __c = __value % __divisor; __value /= __divisor; __p -= 4; - std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4); + std::memcpy(__p, &_LIBCPP_ITOA_TABLE_BASE_2[4 * __c], 4); } do { unsigned __c = __value % 2; @@ -418,7 +419,7 @@ unsigned __c = __value % __divisor; __value /= __divisor; __p -= 2; - std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2); + std::memcpy(__p, &_LIBCPP_ITOA_TABLE_BASE_8[2 * __c], 2); } do { unsigned __c = __value % 8; @@ -454,7 +455,7 @@ unsigned __c = __value % __divisor; __value /= __divisor; __p -= 2; - std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2); + std::memcpy(__p, &_LIBCPP_ITOA_TABLE_BASE_16[2 * __c], 2); } if (__first != __last) do { diff --git a/libcxx/src/include/ryu/digit_table.h b/libcxx/src/include/ryu/digit_table.h --- a/libcxx/src/include/ryu/digit_table.h +++ b/libcxx/src/include/ryu/digit_table.h @@ -50,7 +50,7 @@ // In order to minimize the diff in the Ryu code between MSVC STL and libc++ // the code uses the name __DIGIT_TABLE. In order to avoid code duplication it // reuses the table already available in libc++. -inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10; +inline constexpr auto& __DIGIT_TABLE = __itoa::__digits_base_10; _LIBCPP_END_NAMESPACE_STD