[libc-commits] [libcxx] [clang-tools-extra] [mlir] [clang] [libc] [llvm] [flang] [lld] [compiler-rt] [lldb] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)
Mark de Wever via libc-commits
libc-commits at lists.llvm.org
Thu Jan 18 11:35:53 PST 2024
================
@@ -19,19 +19,25 @@
#include "test_macros.h"
#include "make_string.h"
+#if _LIBCPP_STD_VER >= 26
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+#endif
+
template <class Context, class To, class From>
void test(From value) {
auto store = std::make_format_args<Context>(value);
const std::basic_format_args<Context> format_args{store};
- std::visit_format_arg(
- [v = To(value)](auto a) {
- if constexpr (std::is_same_v<To, decltype(a)>)
- assert(v == a);
- else
- assert(false);
- },
- format_args.get(0));
+ auto visitor = [v = To(value)](auto a) {
+ if constexpr (std::is_same_v<To, decltype(a)>)
+ assert(v == a);
+ else
+ assert(false);
+ };
+#if _LIBCPP_STD_VER >= 26
+ format_args.get(0).visit(visitor);
+#endif
+ std::visit_format_arg(visitor, format_args.get(0));
----------------
mordante wrote:
If we put this in an `#else` we don't need to disable deprecated warnings right?
This function tests `get` so we don't need to add coverage for the visitor.
This means the code looks like what you did in libcxx/test/support/test_basic_format_arg.h
https://github.com/llvm/llvm-project/pull/76449
More information about the libc-commits
mailing list