Skip to content

Commit deeb936

Browse files
authored
[libc++][format] define __cpp_lib_format. (llvm#98275)
In order to define the format __cpp_lib_format to its initial value (201907) these papers need to be completed: - P0645R10 Text Formatting - P1652R1 Printf corner cases in std::format - 1361R2 Integration of chrono with text formatting The first two have been implemented for a while the latter is almost done. The next value (202106) requires: - P2216R3 std::format improvements which has been implemented The next value (202110) requires: - P2418R2 Add support for std::generator-like types to std::format - P2372R3 Fixing locale handling in chrono formatters The first one has been implemented for a while the latter is almost done. The latter paper is a DR against 1361R2 and both are implemented at the same time. We've had user feedback that the missing of the __cpp_lib_format makes their lives harder (llvm#77773). The missing papers 1361R2 and P2372R3 are very close to completion and might completed before LLVM-19, but it will be a close call. This has been discussed in the monthly libc++ meeting and we decided to set the __cpp_lib_format so it will be set in LLVM-19. Based on the discussion and the implementation status the __cpp_lib_format is set to 202110. Fixes llvm#77773
1 parent 588a6d7 commit deeb936

File tree

5 files changed

+36
-76
lines changed

5 files changed

+36
-76
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Status
234234
---------------------------------------------------------- -----------------
235235
``__cpp_lib_execution`` *unimplemented*
236236
---------------------------------------------------------- -----------------
237-
``__cpp_lib_format`` *unimplemented*
237+
``__cpp_lib_format`` ``202110L``
238238
---------------------------------------------------------- -----------------
239239
``__cpp_lib_format_uchar`` ``202311L``
240240
---------------------------------------------------------- -----------------

libcxx/include/version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ __cpp_lib_execution 201902L <execution>
101101
201603L // C++17
102102
__cpp_lib_expected 202211L <expected>
103103
__cpp_lib_filesystem 201703L <filesystem>
104-
__cpp_lib_format 202106L <format>
104+
__cpp_lib_format 202110L <format>
105105
__cpp_lib_format_path 202403L <filesystem>
106106
__cpp_lib_format_ranges 202207L <format>
107107
__cpp_lib_format_uchar 202311L <format>
@@ -403,7 +403,7 @@ __cpp_lib_void_t 201411L <type_traits>
403403
# define __cpp_lib_erase_if 202002L
404404
# undef __cpp_lib_execution
405405
// # define __cpp_lib_execution 201902L
406-
// # define __cpp_lib_format 202106L
406+
# define __cpp_lib_format 202110L
407407
# define __cpp_lib_format_uchar 202311L
408408
# define __cpp_lib_generic_unordered_lookup 201811L
409409
# define __cpp_lib_int_pow2 202002L

libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Test the feature test macros defined by <format>
1717

1818
/* Constant Value
19-
__cpp_lib_format 202106L [C++20]
19+
__cpp_lib_format 202110L [C++20]
2020
__cpp_lib_format_ranges 202207L [C++23]
2121
__cpp_lib_format_uchar 202311L [C++20]
2222
*/
@@ -68,17 +68,11 @@
6868

6969
#elif TEST_STD_VER == 20
7070

71-
# if !defined(_LIBCPP_VERSION)
72-
# ifndef __cpp_lib_format
73-
# error "__cpp_lib_format should be defined in c++20"
74-
# endif
75-
# if __cpp_lib_format != 202106L
76-
# error "__cpp_lib_format should have the value 202106L in c++20"
77-
# endif
78-
# else // _LIBCPP_VERSION
79-
# ifdef __cpp_lib_format
80-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
81-
# endif
71+
# ifndef __cpp_lib_format
72+
# error "__cpp_lib_format should be defined in c++20"
73+
# endif
74+
# if __cpp_lib_format != 202110L
75+
# error "__cpp_lib_format should have the value 202110L in c++20"
8276
# endif
8377

8478
# ifdef __cpp_lib_format_ranges
@@ -94,17 +88,11 @@
9488

9589
#elif TEST_STD_VER == 23
9690

97-
# if !defined(_LIBCPP_VERSION)
98-
# ifndef __cpp_lib_format
99-
# error "__cpp_lib_format should be defined in c++23"
100-
# endif
101-
# if __cpp_lib_format != 202106L
102-
# error "__cpp_lib_format should have the value 202106L in c++23"
103-
# endif
104-
# else // _LIBCPP_VERSION
105-
# ifdef __cpp_lib_format
106-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
107-
# endif
91+
# ifndef __cpp_lib_format
92+
# error "__cpp_lib_format should be defined in c++23"
93+
# endif
94+
# if __cpp_lib_format != 202110L
95+
# error "__cpp_lib_format should have the value 202110L in c++23"
10896
# endif
10997

11098
# ifndef __cpp_lib_format_ranges
@@ -123,17 +111,11 @@
123111

124112
#elif TEST_STD_VER > 23
125113

126-
# if !defined(_LIBCPP_VERSION)
127-
# ifndef __cpp_lib_format
128-
# error "__cpp_lib_format should be defined in c++26"
129-
# endif
130-
# if __cpp_lib_format != 202106L
131-
# error "__cpp_lib_format should have the value 202106L in c++26"
132-
# endif
133-
# else // _LIBCPP_VERSION
134-
# ifdef __cpp_lib_format
135-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
136-
# endif
114+
# ifndef __cpp_lib_format
115+
# error "__cpp_lib_format should be defined in c++26"
116+
# endif
117+
# if __cpp_lib_format != 202110L
118+
# error "__cpp_lib_format should have the value 202110L in c++26"
137119
# endif
138120

139121
# ifndef __cpp_lib_format_ranges

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
201902L [C++20]
8989
__cpp_lib_expected 202211L [C++23]
9090
__cpp_lib_filesystem 201703L [C++17]
91-
__cpp_lib_format 202106L [C++20]
91+
__cpp_lib_format 202110L [C++20]
9292
__cpp_lib_format_path 202403L [C++26]
9393
__cpp_lib_format_ranges 202207L [C++23]
9494
__cpp_lib_format_uchar 202311L [C++20]
@@ -3618,17 +3618,11 @@
36183618
# endif
36193619
# endif
36203620

3621-
# if !defined(_LIBCPP_VERSION)
3622-
# ifndef __cpp_lib_format
3623-
# error "__cpp_lib_format should be defined in c++20"
3624-
# endif
3625-
# if __cpp_lib_format != 202106L
3626-
# error "__cpp_lib_format should have the value 202106L in c++20"
3627-
# endif
3628-
# else // _LIBCPP_VERSION
3629-
# ifdef __cpp_lib_format
3630-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
3631-
# endif
3621+
# ifndef __cpp_lib_format
3622+
# error "__cpp_lib_format should be defined in c++20"
3623+
# endif
3624+
# if __cpp_lib_format != 202110L
3625+
# error "__cpp_lib_format should have the value 202110L in c++20"
36323626
# endif
36333627

36343628
# ifdef __cpp_lib_format_path
@@ -5063,17 +5057,11 @@
50635057
# endif
50645058
# endif
50655059

5066-
# if !defined(_LIBCPP_VERSION)
5067-
# ifndef __cpp_lib_format
5068-
# error "__cpp_lib_format should be defined in c++23"
5069-
# endif
5070-
# if __cpp_lib_format != 202106L
5071-
# error "__cpp_lib_format should have the value 202106L in c++23"
5072-
# endif
5073-
# else // _LIBCPP_VERSION
5074-
# ifdef __cpp_lib_format
5075-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
5076-
# endif
5060+
# ifndef __cpp_lib_format
5061+
# error "__cpp_lib_format should be defined in c++23"
5062+
# endif
5063+
# if __cpp_lib_format != 202110L
5064+
# error "__cpp_lib_format should have the value 202110L in c++23"
50775065
# endif
50785066

50795067
# ifdef __cpp_lib_format_path
@@ -6748,17 +6736,11 @@
67486736
# endif
67496737
# endif
67506738

6751-
# if !defined(_LIBCPP_VERSION)
6752-
# ifndef __cpp_lib_format
6753-
# error "__cpp_lib_format should be defined in c++26"
6754-
# endif
6755-
# if __cpp_lib_format != 202106L
6756-
# error "__cpp_lib_format should have the value 202106L in c++26"
6757-
# endif
6758-
# else // _LIBCPP_VERSION
6759-
# ifdef __cpp_lib_format
6760-
# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!"
6761-
# endif
6739+
# ifndef __cpp_lib_format
6740+
# error "__cpp_lib_format should be defined in c++26"
6741+
# endif
6742+
# if __cpp_lib_format != 202110L
6743+
# error "__cpp_lib_format should have the value 202110L in c++26"
67626744
# endif
67636745

67646746
# if !defined(_LIBCPP_VERSION)

libcxx/utils/generate_feature_test_macro_components.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,7 @@ def add_version_header(tc):
507507
{
508508
"name": "__cpp_lib_format",
509509
"values": {
510-
# "c++20": 201907 Not implemented P1361R2 Integration of chrono with text formatting
511-
# "c++20": 202106 Fully implemented
512-
# "c++20": 202110 Not implemented P2372R3 Fixing locale handling in chrono formatters
513-
"c++20": 202106,
510+
"c++20": 202110,
514511
# "c++23": 202207, Not implemented P2419R2 Clarify handling of encodings in localized formatting of chrono types
515512
# "c++26": 202306, P2637R3 Member Visit (implemented)
516513
# "c++26": 202311, P2918R2 Runtime format strings II (implemented)
@@ -520,7 +517,6 @@ def add_version_header(tc):
520517
# 202305 P2757R3 Type-checking format args
521518
# 202306 P2637R3 Member Visit
522519
"headers": ["format"],
523-
"unimplemented": True,
524520
},
525521
{
526522
"name": "__cpp_lib_format_path",

0 commit comments

Comments
 (0)