[libcxx-commits] [libcxx] [libc++] cv-qualified types in atomic and atomic_ref (P3323R1) (PR #121414)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 12 04:48:27 PST 2025


================
@@ -29,7 +29,13 @@
 #include <__cstddef/ptrdiff_t.h>
 #include <__memory/addressof.h>
 #include <__type_traits/has_unique_object_representation.h>
+#include <__type_traits/is_const.h>
----------------
huixie90 wrote:

sorry just a question:
I did not follow the paper but do you know what is the reason to support `atomic_ref<const Foo>`. One possible use case I can think of is something like

```cpp
int val = 0;

// writer thread
atomic_ref<int> a(val);
a.store(...);

// reader thread
atomic_ref<const int> a(val);
a.load(...);
```

Or, did I misunderstand anything? Could you please add a test for the use case that is designed for? (Currently I only see a test for `const T` in `load`, where it inits a variable and `load` it. which is a must have test case, but I guess it does not represent the real use case it is designed for)

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


More information about the libcxx-commits mailing list