[libcxx-commits] [libcxx] [libc++] <experimental/simd> Add swap functions of simd reference (PR #86478)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 22 01:31:53 PDT 2024


================
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/simd>
+//
+// [simd.reference]
+// friend void swap(reference&& a, reference&& b) noexcept;
+// friend void swap(value_type& a, reference&& b) noexcept;
+// friend void swap(reference&& a, value_type& b) noexcept;
+
+#include "../test_utils.h"
+#include <experimental/simd>
+
+namespace ex = std::experimental::parallelism_v2;
+
+template <class T, std::size_t>
+struct CheckSimdRefSwap {
+  template <class SimdAbi>
+  void operator()() {
+    ex::simd<T, SimdAbi> origin_simd_1(1);
+    ex::simd<T, SimdAbi> origin_simd_2(2);
+    T value = 3;
+
+    static_assert(noexcept(swap(origin_simd_1[0], origin_simd_2[0])));
----------------
philnik777 wrote:

Please make sure that the overload can be called when qualified. I don't think that's the case right now, since you wrote them as hidden friends.

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


More information about the libcxx-commits mailing list