[libcxx-commits] [libcxx] [libc++] cv-qualified types in atomic and atomic_ref (P3323R1) (PR #121414)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 31 12:52:03 PDT 2025
================
@@ -23,40 +23,63 @@
template <typename T>
struct TestLoad {
void operator()() const {
- T x(T(1));
+ using Unqualified = std::remove_cv_t<T>;
+
+ T x(Unqualified(1));
std::atomic_ref<T> const a(x);
{
- std::same_as<T> decltype(auto) y = a.load();
- assert(y == T(1));
+ std::same_as<Unqualified> decltype(auto) y = a.load();
+ assert(y == Unqualified(1));
ASSERT_NOEXCEPT(a.load());
}
{
- std::same_as<T> decltype(auto) y = a.load(std::memory_order_seq_cst);
- assert(y == T(1));
+ std::same_as<Unqualified> decltype(auto) y = a.load(std::memory_order_seq_cst);
+ assert(y == Unqualified(1));
ASSERT_NOEXCEPT(a.load(std::memory_order_seq_cst));
}
- // memory_order::seq_cst
- {
- auto store = [](std::atomic_ref<T> const& y, T, T new_val) { y.store(new_val); };
- auto load_no_arg = [](std::atomic_ref<T> const& y) { return y.load(); };
- auto load_with_order = [](std::atomic_ref<T> const& y) { return y.load(std::memory_order::seq_cst); };
- test_seq_cst<T>(store, load_no_arg);
- test_seq_cst<T>(store, load_with_order);
- }
+ if constexpr (!std::is_const_v<T>) { // FIXME
----------------
ldionne wrote:
You can change the comment to a short explanation of why we can't test that, something like:
```
// The test helper needs the ability to store to the atomic_ref, which doesn't work for a const T.
```
https://github.com/llvm/llvm-project/pull/121414
More information about the libcxx-commits
mailing list