Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_to_chars`` *unimplemented*
---------------------------------------------------------- -----------------
``__cpp_lib_to_string`` *unimplemented*
``__cpp_lib_to_string`` ``202306L``
---------------------------------------------------------- -----------------
``__cpp_lib_tuple_like`` *unimplemented*
---------------------------------------------------------- -----------------
Expand Down
30 changes: 30 additions & 0 deletions libcxx/docs/Status/Cxx2cPapers.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
"Paper #","Paper Name","Meeting","Status","First released version","Notes"
<<<<<<< HEAD
"`P2497R0 <https://wg21.link/P2497R0>`__","Testing for success or failure of ``<charconv>`` functions","2023-06 (Varna)","|Complete|","18",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","","",""
"`P2587R3 <https://wg21.link/P2587R3>`__","``to_string`` or not ``to_string``","2023-06 (Varna)","|Complete|","XX",""
"`P2562R1 <https://wg21.link/P2562R1>`__","``constexpr`` Stable Sorting","2023-06 (Varna)","|Partial|","20",""
"`P2545R4 <https://wg21.link/P2545R4>`__","Read-Copy Update (RCU)","2023-06 (Varna)","","",""
"`P2530R3 <https://wg21.link/P2530R3>`__","Hazard Pointers for C++26","2023-06 (Varna)","","",""
"`P2538R1 <https://wg21.link/P2538R1>`__","ADL-proof ``std::projected``","2023-06 (Varna)","|Complete|","18",""
"`P2495R3 <https://wg21.link/P2495R3>`__","Interfacing ``stringstream``\s with ``string_view``","2023-06 (Varna)","|Complete|","19",""
"`P2510R3 <https://wg21.link/P2510R3>`__","Formatting pointers","2023-06 (Varna)","|Complete|","17","Implemented as a DR against C++20. (MSVC STL and libstdc++ will do the same.)"
"`P2198R7 <https://wg21.link/P2198R7>`__","Freestanding Feature-Test Macros and Implementation-Defined Extensions","2023-06 (Varna)","","",""
"`P2338R4 <https://wg21.link/P2338R4>`__","Freestanding Library: Character primitives and the C library","2023-06 (Varna)","","",""
"`P2013R5 <https://wg21.link/P2013R5>`__","Freestanding Language: Optional ``::operator new``","2023-06 (Varna)","","",""
"`P2363R5 <https://wg21.link/P2363R5>`__","Extending associative containers with the remaining heterogeneous overloads","2023-06 (Varna)","","",""
"`P1901R2 <https://wg21.link/P1901R2>`__","Enabling the Use of ``weak_ptr`` as Keys in Unordered Associative Containers","2023-06 (Varna)","","",""
"`P1885R12 <https://wg21.link/P1885R12>`__","Naming Text Encodings to Demystify Them","2023-06 (Varna)","","",""
"`P0792R14 <https://wg21.link/P0792R14>`__","``function_ref``: a type-erased callable reference","2023-06 (Varna)","","",""
"`P2874R2 <https://wg21.link/P2874R2>`__","P2874R2: Mandating Annex D Require No More","2023-06 (Varna)","|Complete|","12",""
"`P2757R3 <https://wg21.link/P2757R3>`__","Type-checking format args","2023-06 (Varna)","","",""
"`P2637R3 <https://wg21.link/P2637R3>`__","Member ``visit``","2023-06 (Varna)","|Complete|","19","Change of ``__cpp_lib_variant`` is completed in LLVM 20. Change of ``__cpp_lib_format`` is blocked by `P2419R2 <https://wg21.link/P2419R2>`__."
"`P2641R4 <https://wg21.link/P2641R4>`__","Checking if a ``union`` alternative is active","2023-06 (Varna)","","",""
"`P1759R6 <https://wg21.link/P1759R6>`__","Native handles and file streams","2023-06 (Varna)","|Complete|","18",""
"`P2697R1 <https://wg21.link/P2697R1>`__","Interfacing ``bitset`` with ``string_view``","2023-06 (Varna)","|Complete|","18",""
"`P1383R2 <https://wg21.link/P1383R2>`__","More ``constexpr`` for ``<cmath>`` and ``<complex>``","2023-06 (Varna)","","",""
"`P2734R0 <https://wg21.link/P2734R0>`__","Adding the new SI prefixes","2023-06 (Varna)","|Complete|","17",""
"`P2548R6 <https://wg21.link/P2548R6>`__","``copyable_function``","2023-06 (Varna)","","",""
"`P2714R1 <https://wg21.link/P2714R1>`__","Bind front and back to NTTP callables","2023-06 (Varna)","|Partial|","20",""
"`P2630R4 <https://wg21.link/P2630R4>`__","``submdspan``","2023-06 (Varna)","","",""
=======
"`P2497R0 <https://wg21.link/P2497R0>`__","Testing for success or failure of ``<charconv>`` functions","2023-06 (Varna)","|Complete|","18","`#105357 <https://github.com/llvm/llvm-project/issues/105357>`__",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","","","`#105358 <https://github.com/llvm/llvm-project/issues/105358>`__",""
"`P2587R3 <https://wg21.link/P2587R3>`__","``to_string`` or not ``to_string``","2023-06 (Varna)","","","`#105359 <https://github.com/llvm/llvm-project/issues/105359>`__",""
Expand Down Expand Up @@ -26,6 +55,7 @@
"`P2548R6 <https://wg21.link/P2548R6>`__","``copyable_function``","2023-06 (Varna)","","","`#105387 <https://github.com/llvm/llvm-project/issues/105387>`__",""
"`P2714R1 <https://wg21.link/P2714R1>`__","Bind front and back to NTTP callables","2023-06 (Varna)","|Partial|","20","`#105388 <https://github.com/llvm/llvm-project/issues/105388>`__",""
"`P2630R4 <https://wg21.link/P2630R4>`__","``submdspan``","2023-06 (Varna)","","","`#105389 <https://github.com/llvm/llvm-project/issues/105389>`__",""
>>>>>>> main
"","","","","",""
"`P0543R3 <https://wg21.link/P0543R3>`__","Saturation arithmetic","2023-11 (Kona)","|Complete|","18","`#105390 <https://github.com/llvm/llvm-project/issues/105390>`__",""
"`P2407R5 <https://wg21.link/P2407R5>`__","Freestanding Library: Partial Classes","2023-11 (Kona)","","","`#105391 <https://github.com/llvm/llvm-project/issues/105391>`__",""
Expand Down
22 changes: 22 additions & 0 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -3912,9 +3912,20 @@ _LIBCPP_EXPORTED_FROM_ABI string to_string(long __val);
_LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long __val);
_LIBCPP_EXPORTED_FROM_ABI string to_string(long long __val);
_LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long long __val);

# if _LIBCPP_STD_VER >= 26
_LIBCPP_EXPORTED_FROM_ABI string __to_string(float __val);
_LIBCPP_EXPORTED_FROM_ABI string __to_string(double __val);
_LIBCPP_EXPORTED_FROM_ABI string __to_string(long double __val);

_LIBCPP_HIDE_FROM_ABI string to_string(float __val) { return std::__to_string(__val); }
_LIBCPP_HIDE_FROM_ABI string to_string(double __val) { return std::__to_string(__val); }
_LIBCPP_HIDE_FROM_ABI string to_string(long double __val) { return std::__to_string(__val); }
# else
_LIBCPP_EXPORTED_FROM_ABI string to_string(float __val);
_LIBCPP_EXPORTED_FROM_ABI string to_string(double __val);
_LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val);
# endif // _LIBCPP_STD_VER >= 26

# if _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
Expand All @@ -3933,9 +3944,20 @@ _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long __val);
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long __val);
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long long __val);
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val);

# if _LIBCPP_STD_VER >= 26
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(float __val);
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(double __val);
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(long double __val);

_LIBCPP_HIDE_FROM_ABI wstring to_wstring(float __val) { return std::__to_wstring(__val); }
_LIBCPP_HIDE_FROM_ABI wstring to_wstring(double __val) { return std::__to_wstring(__val); }
_LIBCPP_HIDE_FROM_ABI wstring to_wstring(long double __val) { return std::__to_wstring(__val); }
# else
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val);
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val);
_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val);
# endif
# endif // _LIBCPP_HAS_WIDE_CHARACTERS

template <class _CharT, class _Traits, class _Allocator>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_text_encoding 202306L
# undef __cpp_lib_to_chars
// # define __cpp_lib_to_chars 202306L
// # define __cpp_lib_to_string 202306L
# define __cpp_lib_to_string 202306L
# undef __cpp_lib_tuple_like
// # define __cpp_lib_tuple_like 202311L
# undef __cpp_lib_variant
Expand Down
11 changes: 11 additions & 0 deletions libcxx/src/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cerrno>
#include <charconv>
#include <cstdlib>
#include <format>
#include <limits>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -372,6 +373,16 @@ wstring to_wstring(unsigned long val) { return i_to_string<wstring>(val); }
wstring to_wstring(unsigned long long val) { return i_to_string<wstring>(val); }
#endif

_LIBCPP_EXPORTED_FROM_ABI string __to_string(float __val) { return std::format("{}", __val); }
_LIBCPP_EXPORTED_FROM_ABI string __to_string(double __val) { return std::format("{}", __val); }
_LIBCPP_EXPORTED_FROM_ABI string __to_string(long double __val) { return std::format("{}", __val); }

#if _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(float __val) { return std::format(L"{}", __val); }
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(double __val) { return std::format(L"{}", __val); }
_LIBCPP_EXPORTED_FROM_ABI wstring __to_wstring(long double __val) { return std::format(L"{}", __val); }
#endif

string to_string(float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@
# error "__cpp_lib_string_view should have the value 202403L in c++26"
# endif

<<<<<<< HEAD
# ifndef __cpp_lib_to_string
# error "__cpp_lib_to_string should be defined in c++26"
# endif
# if __cpp_lib_to_string != 202306L
# error "__cpp_lib_to_string should have the value 202306L in c++26"
# endif
=======
# if !defined(_LIBCPP_VERSION)
# ifndef __cpp_lib_to_string
# error "__cpp_lib_to_string should be defined in c++26"
Expand All @@ -482,6 +490,7 @@
# error "__cpp_lib_to_string should not be defined because it is unimplemented in libc++!"
# endif
# endif
>>>>>>> main

#endif // TEST_STD_VER > 23

Expand Down
Loading
Loading