[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
Fri Jun 21 02:00:35 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:
Yeah, the specification is indeed as a hidden friend. OTOH if that got into the standard it would almost certainly result in an LWG issue, since this is unprecedented. I'd go ahead with the current version and add a comment to the test that we (or at least I) believe that this is a wording defect.
https://github.com/llvm/llvm-project/pull/86478
More information about the libcxx-commits
mailing list