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