[libcxx-commits] [libcxx] [libc++] Implement C++20 atomic_ref (PR #76647)
Damien L-G via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 7 06:10:59 PST 2024
================
@@ -0,0 +1,47 @@
+//
+// 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
+
+// operator T() const noexcept;
+
+#include <atomic>
+#include <cassert>
+#include <type_traits>
+
+#include "test_macros.h"
+
+template <typename T>
+void test_convert() {
+ T x(T(1));
+ std::atomic_ref<T> a(x);
+
+ assert(a == T(1));
+
+ ASSERT_NOEXCEPT(T(a));
+ static_assert(std::is_nothrow_convertible_v<std::atomic_ref<T>, T>);
+}
+
+void test() {
+ test_convert<int>();
+
+ test_convert<float>();
+
+ test_convert<int*>();
+
----------------
dalg24 wrote:
Done for that file. Still using that pattern in other places when I need multiple value representations. Could not think of an elegant way to avoid it.
https://github.com/llvm/llvm-project/pull/76647
More information about the libcxx-commits
mailing list