[flang] [clang] [lldb] [libc] [libcxx] [llvm] [compiler-rt] [clang-tools-extra] [libc++][variant] P2637R3: Member `visit` (`std::variant`) (PR #76447)

Mark de Wever via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 30 04:10:45 PST 2023


================
@@ -0,0 +1,268 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <variant>
+
+// class variant;
+
+// template<class Self, class Visitor>
+//   constexpr decltype(auto) visit(this Self&&, Visitor&&); // since C++26
+
+#include <cassert>
+#include <memory>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <variant>
+
+#include "test_macros.h"
+#include "variant_test_helpers.h"
+
+void test_call_operator_forwarding() {
+  using Fn = ForwardingCallObject;
+  Fn obj{};
+  const Fn& cobj = obj;
+
+  { // test call operator forwarding - no variant
+    // non-member
+    {
+      std::visit(obj);
+      assert(Fn::check_call<>(CT_NonConst | CT_LValue));
----------------
mordante wrote:

I assume this code is copied from somewhere else. I find it quite hard to read what is tested here.

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


More information about the cfe-commits mailing list