tmp/tmpfy4fgiiu/{from.md → to.md}
RENAMED
|
@@ -40,16 +40,37 @@ enabled specializations:
|
|
| 40 |
template<> struct formatter<void*, charT>;
|
| 41 |
template<> struct formatter<const void*, charT>;
|
| 42 |
```
|
| 43 |
|
| 44 |
The `parse` member functions of these formatters interpret the format
|
| 45 |
-
specification as a *std-format-spec* as described in
|
| 46 |
[[format.string.std]].
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
For any types `T` and `charT` for which neither the library nor the user
|
| 53 |
provides an explicit or partial specialization of the class template
|
| 54 |
`formatter`, `formatter<T, charT>` is disabled.
|
| 55 |
|
|
@@ -71,10 +92,11 @@ An enabled specialization `formatter<T, charT>` meets the requirements
|
|
| 71 |
|
| 72 |
[*Example 1*:
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
#include <format>
|
|
|
|
| 76 |
|
| 77 |
enum color { red, green, blue };
|
| 78 |
const char* color_names[] = { "red", "green", "blue" };
|
| 79 |
|
| 80 |
template<> struct std::formatter<color> : std::formatter<const char*> {
|
|
|
|
| 40 |
template<> struct formatter<void*, charT>;
|
| 41 |
template<> struct formatter<const void*, charT>;
|
| 42 |
```
|
| 43 |
|
| 44 |
The `parse` member functions of these formatters interpret the format
|
| 45 |
+
specification as a *std-format-spec* as described in
|
| 46 |
[[format.string.std]].
|
| 47 |
|
| 48 |
+
Unless specified otherwise, for each type `T` for which a `formatter`
|
| 49 |
+
specialization is provided by the library, each of the headers provides
|
| 50 |
+
the following specialization:
|
| 51 |
+
|
| 52 |
+
``` cpp
|
| 53 |
+
template<> inline constexpr bool enable_nonlocking_formatter_optimization<T> = true;
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
[*Note 1*: Specializations such as `formatter<wchar_t, char>` that
|
| 57 |
+
would require implicit multibyte / wide string or character conversion
|
| 58 |
+
are disabled. — *end note*]
|
| 59 |
+
|
| 60 |
+
The header `<format>` provides the following disabled specializations:
|
| 61 |
+
|
| 62 |
+
- The string type specializations
|
| 63 |
+
``` cpp
|
| 64 |
+
template<> struct formatter<char*, wchar_t>;
|
| 65 |
+
template<> struct formatter<const char*, wchar_t>;
|
| 66 |
+
template<size_t N> struct formatter<char[N], wchar_t>;
|
| 67 |
+
template<class traits, class Allocator>
|
| 68 |
+
struct formatter<basic_string<char, traits, Allocator>, wchar_t>;
|
| 69 |
+
template<class traits>
|
| 70 |
+
struct formatter<basic_string_view<char, traits>, wchar_t>;
|
| 71 |
+
```
|
| 72 |
|
| 73 |
For any types `T` and `charT` for which neither the library nor the user
|
| 74 |
provides an explicit or partial specialization of the class template
|
| 75 |
`formatter`, `formatter<T, charT>` is disabled.
|
| 76 |
|
|
|
|
| 92 |
|
| 93 |
[*Example 1*:
|
| 94 |
|
| 95 |
``` cpp
|
| 96 |
#include <format>
|
| 97 |
+
#include <string>
|
| 98 |
|
| 99 |
enum color { red, green, blue };
|
| 100 |
const char* color_names[] = { "red", "green", "blue" };
|
| 101 |
|
| 102 |
template<> struct std::formatter<color> : std::formatter<const char*> {
|