Skip to content

Commit e17ec8e

Browse files
committed
[libc++] Make charconv require C++17 or later.
Implementing the paper P2291R3 Add Constexpr Modifiers to Functions to_chars and from_chars for Integral Types in <charconv> Header Gives issues in language versions prior to C++17. As suggested in D131855 disable the code prior to C++17. This removes libc++'s extension. Reviewed By: ldionne, #libc_vendors, #libc, philnik Differential Revision: https://reviews.llvm.org/D133216
1 parent a8fbd11 commit e17ec8e

File tree

13 files changed

+26
-36
lines changed

13 files changed

+26
-36
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Deprecations and Removals
7878
reach out to the libc++ developers if you find something missing in the new
7979
configuration system.
8080

81+
- The functions ``to_chars`` and ``from_chars`` for integral types are
82+
available starting with C++17. Libc++ offered these functions in C++11 and
83+
C++14 as an undocumented extension. This extension makes it hard to implement
84+
the C++23 paper that makes these functions ``constexpr``, therefore the
85+
extension has been removed.
86+
8187
Upcoming Deprecations and Removals
8288
----------------------------------
8389

libcxx/include/__charconv/chars_format.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22-
#ifndef _LIBCPP_CXX03_LANG
22+
#if _LIBCPP_STD_VER > 14
2323

2424
enum class _LIBCPP_ENUM_VIS chars_format
2525
{
@@ -70,7 +70,7 @@ operator^=(chars_format& __x, chars_format __y) {
7070
return __x;
7171
}
7272

73-
#endif // _LIBCPP_CXX03_LANG
73+
#endif // _LIBCPP_STD_VER > 14
7474

7575
_LIBCPP_END_NAMESPACE_STD
7676

libcxx/include/__charconv/from_chars_result.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22-
#ifndef _LIBCPP_CXX03_LANG
22+
#if _LIBCPP_STD_VER > 14
2323

2424
struct _LIBCPP_TYPE_VIS from_chars_result
2525
{
@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result
3030
# endif
3131
};
3232

33-
#endif // _LIBCPP_CXX03_LANG
33+
#endif // _LIBCPP_STD_VER > 14
3434

3535
_LIBCPP_END_NAMESPACE_STD
3636

libcxx/include/__charconv/tables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22-
#ifndef _LIBCPP_CXX03_LANG
22+
#if _LIBCPP_STD_VER > 14
2323

2424
namespace __itoa {
2525

@@ -173,7 +173,7 @@ const char __table<_Tp>::__digits_base_10[200] = {
173173

174174
} // namespace __itoa
175175

176-
#endif // _LIBCPP_CXX03_LANG
176+
#endif // _LIBCPP_STD_VER > 14
177177

178178
_LIBCPP_END_NAMESPACE_STD
179179

libcxx/include/__charconv/to_chars_base_10.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS
2525

2626
_LIBCPP_BEGIN_NAMESPACE_STD
2727

28-
#ifndef _LIBCPP_CXX03_LANG
28+
#if _LIBCPP_STD_VER > 14
2929

3030
namespace __itoa {
3131

@@ -176,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __
176176
# endif
177177
} // namespace __itoa
178178

179-
#endif // _LIBCPP_CXX03_LANG
179+
#endif // _LIBCPP_STD_VER > 14
180180

181181
_LIBCPP_END_NAMESPACE_STD
182182

libcxx/include/__charconv/to_chars_result.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22-
#ifndef _LIBCPP_CXX03_LANG
22+
#if _LIBCPP_STD_VER > 14
2323

2424
struct _LIBCPP_TYPE_VIS to_chars_result
2525
{
@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result
3030
# endif
3131
};
3232

33-
#endif // _LIBCPP_CXX03_LANG
33+
#endif // _LIBCPP_STD_VER > 14
3434

3535
_LIBCPP_END_NAMESPACE_STD
3636

libcxx/include/charconv

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ _LIBCPP_PUSH_MACROS
106106

107107
_LIBCPP_BEGIN_NAMESPACE_STD
108108

109-
#ifndef _LIBCPP_CXX03_LANG
109+
#if _LIBCPP_STD_VER > 14
110110

111111
to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
112112
from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
@@ -776,10 +776,6 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
776776
return __from_chars_integral(__first, __last, __value, __base);
777777
}
778778

779-
// Floating-point implementation starts here.
780-
// Unlike the other parts of charconv this is only available in C++17 and newer.
781-
#if _LIBCPP_STD_VER > 14
782-
783779
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
784780
to_chars_result to_chars(char* __first, char* __last, float __value);
785781

@@ -807,8 +803,7 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form
807803
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
808804
to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
809805

810-
# endif // _LIBCPP_STD_VER > 14
811-
#endif // _LIBCPP_CXX03_LANG
806+
#endif // _LIBCPP_STD_VER > 14
812807

813808
_LIBCPP_END_NAMESPACE_STD
814809

libcxx/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03
10-
// UNSUPPORTED: !stdlib=libc++ && c++11
11-
// UNSUPPORTED: !stdlib=libc++ && c++14
9+
// UNSUPPORTED: c++03, c++11, c++14
10+
1211
// <charconv>
1312

1413
// In

libcxx/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03
10-
// UNSUPPORTED: !stdlib=libc++ && c++11
11-
// UNSUPPORTED: !stdlib=libc++ && c++14
9+
// UNSUPPORTED: c++03, c++11, c++14
1210

1311
// <charconv>
1412

libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03
10-
// UNSUPPORTED: !stdlib=libc++ && c++11
11-
// UNSUPPORTED: !stdlib=libc++ && c++14
9+
// UNSUPPORTED: c++03, c++11, c++14
1210

1311
// <charconv>
1412

0 commit comments

Comments
 (0)