[libcxx-commits] [libcxx] [libc++] Implement C++20 atomic_ref (PR #76647)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 7 13:35:05 PDT 2024


================
@@ -0,0 +1,54 @@
+//
+// 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
+
+// T operator=(T) const noexcept;
+
+#include <atomic>
+#include <cassert>
+#include <type_traits>
+
+#include "atomic_helpers.h"
+#include "test_helper.h"
+#include "test_macros.h"
+
+template <typename T>
+struct TestAssign {
+  void operator()() const {
+    T x(T(1));
+    std::atomic_ref<T> const a(x);
+
+    a = T(2);
----------------
ldionne wrote:

You should test that the return type of `operator=` is `T`, and that it returns the right value.

```
decltype(auto) std::same_as<T> result = (a = T(2));
assert(result == T(2));
```

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


More information about the libcxx-commits mailing list