@@ -96,7 +96,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t __get_packed_type(uint64_t __types, size
96
96
97
97
} // namespace __format
98
98
99
- // This function is not user obervable , so it can directly use the non-standard
99
+ // This function is not user observable , so it can directly use the non-standard
100
100
// types of the "variant". See __arg_t for more details.
101
101
template <class _Visitor , class _Context >
102
102
_LIBCPP_HIDE_FROM_ABI decltype (auto ) __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
@@ -147,6 +147,59 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
147
147
__libcpp_unreachable ();
148
148
}
149
149
150
+ # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
151
+
152
+ template <class _Rp , class _Visitor , class _Context >
153
+ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg (_Visitor&& __vis, basic_format_arg<_Context> __arg) {
154
+ switch (__arg.__type_ ) {
155
+ case __format::__arg_t ::__none:
156
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__monostate_ );
157
+ case __format::__arg_t ::__boolean:
158
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__boolean_ );
159
+ case __format::__arg_t ::__char_type:
160
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__char_type_ );
161
+ case __format::__arg_t ::__int:
162
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__int_ );
163
+ case __format::__arg_t ::__long_long:
164
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__long_long_ );
165
+ case __format::__arg_t ::__i128:
166
+ # ifndef _LIBCPP_HAS_NO_INT128
167
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__i128_ );
168
+ # else
169
+ __libcpp_unreachable ();
170
+ # endif
171
+ case __format::__arg_t ::__unsigned:
172
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__unsigned_ );
173
+ case __format::__arg_t ::__unsigned_long_long:
174
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__unsigned_long_long_ );
175
+ case __format::__arg_t ::__u128:
176
+ # ifndef _LIBCPP_HAS_NO_INT128
177
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__u128_ );
178
+ # else
179
+ __libcpp_unreachable ();
180
+ # endif
181
+ case __format::__arg_t ::__float:
182
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__float_ );
183
+ case __format::__arg_t ::__double:
184
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__double_ );
185
+ case __format::__arg_t ::__long_double:
186
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__long_double_ );
187
+ case __format::__arg_t ::__const_char_type_ptr:
188
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__const_char_type_ptr_ );
189
+ case __format::__arg_t ::__string_view:
190
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__string_view_ );
191
+ case __format::__arg_t ::__ptr:
192
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_ .__ptr_ );
193
+ case __format::__arg_t ::__handle:
194
+ return std::invoke_r<_Rp>(
195
+ std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__arg.__value_ .__handle_ });
196
+ }
197
+
198
+ __libcpp_unreachable ();
199
+ }
200
+
201
+ # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
202
+
150
203
// / Contains the values used in basic_format_arg.
151
204
// /
152
205
// / This is a separate type so it's possible to store the values and types in
@@ -230,6 +283,52 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg {
230
283
231
284
_LIBCPP_HIDE_FROM_ABI explicit operator bool () const noexcept { return __type_ != __format::__arg_t ::__none; }
232
285
286
+ # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
287
+
288
+ // This function is user facing, so it must wrap the non-standard types of
289
+ // the "variant" in a handle to stay conforming. See __arg_t for more details.
290
+ template <class _Visitor >
291
+ _LIBCPP_HIDE_FROM_ABI decltype (auto ) visit(this basic_format_arg __arg, _Visitor&& __vis) {
292
+ switch (__arg.__type_ ) {
293
+ # ifndef _LIBCPP_HAS_NO_INT128
294
+ case __format::__arg_t ::__i128: {
295
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_ .__i128_ };
296
+ return std::invoke (std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
297
+ }
298
+
299
+ case __format::__arg_t ::__u128: {
300
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_ .__u128_ };
301
+ return std::invoke (std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
302
+ }
303
+ # endif
304
+ default :
305
+ return std::__visit_format_arg (std::forward<_Visitor>(__vis), __arg);
306
+ }
307
+ }
308
+
309
+ // This function is user facing, so it must wrap the non-standard types of
310
+ // the "variant" in a handle to stay conforming. See __arg_t for more details.
311
+ template <class _Rp , class _Visitor >
312
+ _LIBCPP_HIDE_FROM_ABI _Rp visit (this basic_format_arg __arg, _Visitor&& __vis) {
313
+ switch (__arg.__type_ ) {
314
+ # ifndef _LIBCPP_HAS_NO_INT128
315
+ case __format::__arg_t ::__i128: {
316
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_ .__i128_ };
317
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
318
+ }
319
+
320
+ case __format::__arg_t ::__u128: {
321
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_ .__u128_ };
322
+ return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
323
+ }
324
+ # endif
325
+ default :
326
+ return std::__visit_format_arg<_Rp>(std::forward<_Visitor>(__vis), __arg);
327
+ }
328
+ }
329
+
330
+ # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
331
+
233
332
private:
234
333
using char_type = typename _Context::char_type;
235
334
@@ -270,7 +369,11 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {
270
369
// This function is user facing, so it must wrap the non-standard types of
271
370
// the "variant" in a handle to stay conforming. See __arg_t for more details.
272
371
template <class _Visitor , class _Context >
273
- _LIBCPP_HIDE_FROM_ABI decltype (auto ) visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
372
+ # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
373
+ _LIBCPP_DEPRECATED_IN_CXX26
374
+ # endif
375
+ _LIBCPP_HIDE_FROM_ABI decltype (auto )
376
+ visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
274
377
switch (__arg.__type_ ) {
275
378
# ifndef _LIBCPP_HAS_NO_INT128
276
379
case __format::__arg_t ::__i128: {
@@ -282,7 +385,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_fo
282
385
typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_ .__u128_ };
283
386
return std::invoke (std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
284
387
}
285
- # endif
388
+ # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
286
389
default :
287
390
return std::__visit_format_arg (std::forward<_Visitor>(__vis), __arg);
288
391
}
0 commit comments