[libcxx-commits] [libcxx] [libc++][atomic] P2835R7: Expose `std::atomic_ref`'s object address (PR #162236)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 7 00:41:00 PDT 2025


================
@@ -0,0 +1,37 @@
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// XFAIL: !has-64-bit-atomics
+// XFAIL: !has-1024-bit-atomics
+
+// constexpr T* address() const noexcept;
+
+#include <atomic>
+#include <cassert>
+
+#include "atomic_helpers.h"
+#include "test_macros.h"
+
+template <typename T>
+struct TestAddress {
+  void operator()() const {
+    T x(T(1));
+    std::atomic_ref<T> const a(x);
+
+    assert(a.address() == std::addressof(x));
+
+    static_assert(noexcept((a.address())));
----------------
frederick-vs-ja wrote:

`constexpr` on `address` doesn't seem tested. I think it's better to reorganize `TestAddress` to test `constexpr` together.

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


More information about the libcxx-commits mailing list