[libcxx-commits] [flang] [mlir] [clang-tools-extra] [llvm] [clang] [libc] [lld] [lldb] [compiler-rt] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 18 11:35:52 PST 2024
================
@@ -163,20 +163,26 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context<typename __format::__retarget_bu
# endif
__ctx_(std::addressof(__ctx)),
__arg_([](void* __c, size_t __id) {
- return std::visit_format_arg(
- [&](auto __arg) -> basic_format_arg<basic_format_context> {
- if constexpr (same_as<decltype(__arg), monostate>)
- return {};
- else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
- // At the moment it's not possible for formatting to use a re-targeted handle.
- // TODO FMT add this when support is needed.
- std::__throw_format_error("Re-targeting handle not supported");
- else
- return basic_format_arg<basic_format_context>{
- __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
- __basic_format_arg_value<basic_format_context>(__arg)};
- },
- static_cast<_Context*>(__c)->arg(__id));
+ auto __visitor = [&](auto __arg) -> basic_format_arg<basic_format_context> {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ return {};
+ else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
+ // At the moment it's not possible for formatting to use a re-targeted handle.
+ // TODO FMT add this when support is needed.
+ std::__throw_format_error("Re-targeting handle not supported");
+ else
+ return basic_format_arg<basic_format_context>{
+ __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
+ __basic_format_arg_value<basic_format_context>(__arg)};
+ };
+# if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || _LIBCPP_CLANG_VER >= 1800)
+ return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
+# else
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
----------------
mordante wrote:
```suggestion
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
```
https://github.com/llvm/llvm-project/pull/76449
More information about the libcxx-commits
mailing list