Skip to content
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

P0019R8 atomic_ref #2

Closed
StephanTLavavej opened this issue Sep 5, 2019 · 3 comments · Fixed by #843
Closed

P0019R8 atomic_ref #2

StephanTLavavej opened this issue Sep 5, 2019 · 3 comments · Fixed by #843
Labels
cxx20 C++20 feature fixed Something works now, yay!
Milestone

Comments

@StephanTLavavej
Copy link
Member

StephanTLavavej commented Sep 5, 2019

P0019R8 atomic_ref
P1960R0 atomic_ref Cleanup (note: this paper made minor changes to other wording)

LWG-3160 atomic_ref() = delete; should be deleted

Feature-test macro as of WG21-N4842, added by WG21-P1902:
#define __cpp_lib_atomic_ref 201806L

@AlexGuteniev
Copy link
Contributor

I have a question on this one.

It appears that atomic_ref is "the same as atomic, but reference". So easy way of implementing it could be adding support for references in _Atomic_storage and other classes. But on the other hand, ABI should be preserved, to avoid making this vNext.

So I guess the best way to implement atomic_ref is to re-use existing _Atomic_storage so that it is both extended to support atomic_ref and ABI-unchanged for atomic.

Want you to confirm that.

@AlexGuteniev
Copy link
Contributor

AlexGuteniev commented May 17, 2020

Also I believe that #694 should be merged prior to starting work on this, as they may be changing overlapping parts actually no, changes are merge-able.

@AlexGuteniev
Copy link
Contributor

I think simple change (the way which I put it in draft PR) is possible.

Standard defines:

T* ptr; // exposition only

But as it defines no way to reassign the pointer:

atomic_ref& operator = (const atomic_ref&) = delete

So it may be implemented as reference:

T& ptr; // exposition only

This replacement of value with reference allows for transparent reuse atomic machinery for atomic_ref.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cxx20 C++20 feature fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants