-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libc++][atomic] P2835R7: Expose std::atomic_ref
's object address
#162236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
037a1cb
8b61107
827cc8a
cb00fb1
1f2bcee
0334bfd
d322de6
2c62e4c
dc6e464
871715e
09a79be
3c8a43a
41f7296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// 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 | ||
Zingam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// XFAIL: !has-1024-bit-atomics | ||
|
||
// constexpr T* address() const noexcept; | ||
|
||
#include <atomic> | ||
#include <cassert> | ||
#include <concepts> | ||
|
||
H-G-Hristov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#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()))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird that we haven't added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to complete it after #118382 (P3309R3: constexpr atomic and atomic_ref) |
||
} | ||
}; | ||
|
||
int main(int, char**) { | ||
TestEachAtomicType<TestAddress>()(); | ||
|
||
return 0; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.