[libc-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

Hristo Hristov via libc-commits libc-commits at lists.llvm.org
Thu Jan 18 13:47:52 PST 2024


================
@@ -24,14 +24,17 @@ 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 && (!defined(TEST_COMPILER_CLANG) || TEST_CLANG_VER >= 1800)
----------------
H-G-Hristov wrote:

N.B. `TEST_CLANG_VER` is not defined for Apple Clang.... ???

```c++
#if defined(__apple_build_version__)
// Given AppleClang XX.Y.Z, TEST_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
#define TEST_APPLE_CLANG_VER (__apple_build_version__ / 10000)
#elif defined(__clang_major__)
#define TEST_CLANG_VER (__clang_major__ * 100) + __clang_minor__
#elif defined(__GNUC__)
// Given GCC XX.YY.ZZ, TEST_GCC_VER is XXYYZZ
#define TEST_GCC_VER ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
#endif
```

https://github.com/llvm/llvm-project/pull/76449


More information about the libc-commits mailing list