aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/atomics/atomics.ref/address.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/atomics/atomics.ref/address.pass.cpp')
-rw-r--r--libcxx/test/std/atomics/atomics.ref/address.pass.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/libcxx/test/std/atomics/atomics.ref/address.pass.cpp b/libcxx/test/std/atomics/atomics.ref/address.pass.cpp
new file mode 100644
index 0000000..e0db6a9
--- /dev/null
+++ b/libcxx/test/std/atomics/atomics.ref/address.pass.cpp
@@ -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
+
+// constexpr T* address() const noexcept;
+
+#include <atomic>
+#include <cassert>
+#include <concepts>
+#include <memory>
+
+#include "atomic_helpers.h"
+#include "test_macros.h"
+
+template <typename T>
+struct TestAddress {
+ void operator()() const {
+ T x(T(1));
+ const std::atomic_ref<T> a(x);
+
+ std::same_as<T*> decltype(auto) p = a.address();
+ assert(std::addressof(x) == p);
+
+ static_assert(noexcept((a.address())));
+ }
+};
+
+int main(int, char**) {
+ TestEachAtomicType<TestAddress>()();
+
+ return 0;
+}