tmp/tmp6mysx7p4/{from.md → to.md}
RENAMED
|
@@ -6,11 +6,11 @@ namespace std {
|
|
| 6 |
class basic_format_arg {
|
| 7 |
public:
|
| 8 |
class handle;
|
| 9 |
|
| 10 |
private:
|
| 11 |
-
using char_type =
|
| 12 |
|
| 13 |
variant<monostate, bool, char_type,
|
| 14 |
int, unsigned int, long long int, unsigned long long int,
|
| 15 |
float, double, long double,
|
| 16 |
const char_type*, basic_string_view<char_type>,
|
|
@@ -20,10 +20,15 @@ namespace std {
|
|
| 20 |
|
| 21 |
public:
|
| 22 |
basic_format_arg() noexcept;
|
| 23 |
|
| 24 |
explicit operator bool() const noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
};
|
| 26 |
}
|
| 27 |
```
|
| 28 |
|
| 29 |
An instance of `basic_format_arg` provides access to a formatting
|
|
@@ -43,17 +48,17 @@ template<class T> explicit basic_format_arg(T& v) noexcept;
|
|
| 43 |
```
|
| 44 |
|
| 45 |
*Constraints:* `T` satisfies `formattable-with<Context>`.
|
| 46 |
|
| 47 |
*Preconditions:* If `decay_t<T>` is `char_type*` or `const char_type*`,
|
| 48 |
-
`static_cast<const char_type*>(v)` points to
|
| 49 |
|
| 50 |
*Effects:* Let `TD` be `remove_const_t<T>`.
|
| 51 |
|
| 52 |
- If `TD` is `bool` or `char_type`, initializes `value` with `v`;
|
| 53 |
- otherwise, if `TD` is `char` and `char_type` is `wchar_t`, initializes
|
| 54 |
-
`value` with `static_cast<wchar_t>(v)`;
|
| 55 |
- otherwise, if `TD` is a signed integer type [[basic.fundamental]] and
|
| 56 |
`sizeof(TD) <= sizeof(int)`, initializes `value` with
|
| 57 |
`static_cast<int>(v)`;
|
| 58 |
- otherwise, if `TD` is an unsigned integer type and
|
| 59 |
`sizeof(TD) <= sizeof(unsigned int)`, initializes `value` with
|
|
@@ -84,10 +89,26 @@ is ill-formed unless the user provides an enabled specialization of
|
|
| 84 |
explicit operator bool() const noexcept;
|
| 85 |
```
|
| 86 |
|
| 87 |
*Returns:* `!holds_alternative<monostate>(value)`.
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
The class `handle` allows formatting an object of a user-defined type.
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
namespace std {
|
| 93 |
template<class Context>
|
|
@@ -96,12 +117,10 @@ namespace std {
|
|
| 96 |
void (*format_)(basic_format_parse_context<char_type>&,
|
| 97 |
Context&, const void*); // exposition only
|
| 98 |
|
| 99 |
template<class T> explicit handle(T& val) noexcept; // exposition only
|
| 100 |
|
| 101 |
-
friend class basic_format_arg<Context>; // exposition only
|
| 102 |
-
|
| 103 |
public:
|
| 104 |
void format(basic_format_parse_context<char_type>&, Context& ctx) const;
|
| 105 |
};
|
| 106 |
}
|
| 107 |
```
|
|
@@ -134,13 +153,5 @@ Let
|
|
| 134 |
void format(basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx) const;
|
| 135 |
```
|
| 136 |
|
| 137 |
*Effects:* Equivalent to: `format_(parse_ctx, format_ctx, ptr_);`
|
| 138 |
|
| 139 |
-
``` cpp
|
| 140 |
-
template<class Visitor, class Context>
|
| 141 |
-
decltype(auto) visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg);
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
*Effects:* Equivalent to:
|
| 145 |
-
`return visit(std::forward<Visitor>(vis), arg.value);`
|
| 146 |
-
|
|
|
|
| 6 |
class basic_format_arg {
|
| 7 |
public:
|
| 8 |
class handle;
|
| 9 |
|
| 10 |
private:
|
| 11 |
+
using char_type = Context::char_type; // exposition only
|
| 12 |
|
| 13 |
variant<monostate, bool, char_type,
|
| 14 |
int, unsigned int, long long int, unsigned long long int,
|
| 15 |
float, double, long double,
|
| 16 |
const char_type*, basic_string_view<char_type>,
|
|
|
|
| 20 |
|
| 21 |
public:
|
| 22 |
basic_format_arg() noexcept;
|
| 23 |
|
| 24 |
explicit operator bool() const noexcept;
|
| 25 |
+
|
| 26 |
+
template<class Visitor>
|
| 27 |
+
decltype(auto) visit(this basic_format_arg arg, Visitor&& vis);
|
| 28 |
+
template<class R, class Visitor>
|
| 29 |
+
R visit(this basic_format_arg arg, Visitor&& vis);
|
| 30 |
};
|
| 31 |
}
|
| 32 |
```
|
| 33 |
|
| 34 |
An instance of `basic_format_arg` provides access to a formatting
|
|
|
|
| 48 |
```
|
| 49 |
|
| 50 |
*Constraints:* `T` satisfies `formattable-with<Context>`.
|
| 51 |
|
| 52 |
*Preconditions:* If `decay_t<T>` is `char_type*` or `const char_type*`,
|
| 53 |
+
`static_cast<const char_type*>(v)` points to an NTCTS [[defns.ntcts]].
|
| 54 |
|
| 55 |
*Effects:* Let `TD` be `remove_const_t<T>`.
|
| 56 |
|
| 57 |
- If `TD` is `bool` or `char_type`, initializes `value` with `v`;
|
| 58 |
- otherwise, if `TD` is `char` and `char_type` is `wchar_t`, initializes
|
| 59 |
+
`value` with `static_cast<wchar_t>(static_cast<unsigned char>(v))`;
|
| 60 |
- otherwise, if `TD` is a signed integer type [[basic.fundamental]] and
|
| 61 |
`sizeof(TD) <= sizeof(int)`, initializes `value` with
|
| 62 |
`static_cast<int>(v)`;
|
| 63 |
- otherwise, if `TD` is an unsigned integer type and
|
| 64 |
`sizeof(TD) <= sizeof(unsigned int)`, initializes `value` with
|
|
|
|
| 89 |
explicit operator bool() const noexcept;
|
| 90 |
```
|
| 91 |
|
| 92 |
*Returns:* `!holds_alternative<monostate>(value)`.
|
| 93 |
|
| 94 |
+
``` cpp
|
| 95 |
+
template<class Visitor>
|
| 96 |
+
decltype(auto) visit(this basic_format_arg arg, Visitor&& vis);
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
*Effects:* Equivalent to:
|
| 100 |
+
`return arg.value.visit(std::forward<Visitor>(vis));`
|
| 101 |
+
|
| 102 |
+
``` cpp
|
| 103 |
+
template<class R, class Visitor>
|
| 104 |
+
R visit(this basic_format_arg arg, Visitor&& vis);
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
*Effects:* Equivalent to:
|
| 108 |
+
`return arg.value.visit<R>(std::forward<Visitor>(vis));`
|
| 109 |
+
|
| 110 |
The class `handle` allows formatting an object of a user-defined type.
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
namespace std {
|
| 114 |
template<class Context>
|
|
|
|
| 117 |
void (*format_)(basic_format_parse_context<char_type>&,
|
| 118 |
Context&, const void*); // exposition only
|
| 119 |
|
| 120 |
template<class T> explicit handle(T& val) noexcept; // exposition only
|
| 121 |
|
|
|
|
|
|
|
| 122 |
public:
|
| 123 |
void format(basic_format_parse_context<char_type>&, Context& ctx) const;
|
| 124 |
};
|
| 125 |
}
|
| 126 |
```
|
|
|
|
| 153 |
void format(basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx) const;
|
| 154 |
```
|
| 155 |
|
| 156 |
*Effects:* Equivalent to: `format_(parse_ctx, format_ctx, ptr_);`
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|