[libc++][format] Adds char formatter.
Implements the formatter for all fundamental integer types.
[format.formatter.spec]/2.1
The specializations
```
template<> struct formatter<char, char>;
template<> struct formatter<char, wchar_t>;
template<> struct formatter<wchar_t, wchar_t>;
```
This removes the stub implemented in D96664.
Implements parts of:
- P0645 Text Formatting
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D103466
NOKEYCHECK=True
GitOrigin-RevId: 49e736d845d8e1beb3db0abcc782c9525e44f31e
diff --git a/include/format b/include/format
index 6e779fe..d4e24b6 100644
--- a/include/format
+++ b/include/format
@@ -279,6 +279,7 @@
#include <__format/format_parse_context.h>
#include <__format/format_string.h>
#include <__format/formatter.h>
+#include <__format/formatter_char.h>
#include <__format/formatter_integer.h>
#include <__format/formatter_string.h>
#include <__format/parser_std_format_spec.h>
@@ -338,24 +339,7 @@
make_wformat_args(const _Args&... __args) {
return _VSTD::make_format_args<wformat_context>(__args...);
}
-
namespace __format {
-template <class _Tp, class _CharT>
-struct _LIBCPP_TEMPLATE_VIS __formatter_char {
- _LIBCPP_HIDE_FROM_ABI
- auto parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
- // TODO FMT Implement this function.
- return __parse_ctx.begin();
- }
-
- _LIBCPP_HIDE_FROM_ABI
- auto format(_Tp __c, auto& __ctx) -> decltype(__ctx.out()) {
- // TODO FMT Implement the parsed formatting arguments.
- auto __out_it = __ctx.out();
- *__out_it++ = _CharT(__c);
- return __out_it;
- }
-};
template <class _Tp, class _CharT>
requires(is_arithmetic_v<_Tp> &&
@@ -405,20 +389,6 @@
// These specializations are helper stubs and not proper formatters.
// TODO FMT Implement the proper formatter specializations.
-// [format.formatter.spec]/2.1 The specializations
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS formatter<char, char>
- : public __format::__formatter_char<char, char> {};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t>
- : public __format::__formatter_char<char, wchar_t> {};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t>
- : public __format::__formatter_char<wchar_t, wchar_t> {};
-
// [format.formatter.spec]/2.3
// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization