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

Improve no_destructor.h #896

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

frederick-vs-ja
Copy link

  1. Removed dependency on std::aligned_storage (which will be deprecated in C++23; see also P1413 Deprecate std::aligned_storage and std::aligned_union cplusplus/papers#197).
  2. Removed redundant static_asserts.
  3. Guaranteed the placement new-expression calls global operator new.

1. Removed dependency on std::aligned_storage (which will be deprecated in C++23; see also cplusplus/papers#197).
2. Removed redundant static_assert's.
3. Guaranteed the placement new-expression calls global operator new.
@google-cla
Copy link

google-cla bot commented Apr 14, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Apr 14, 2021
@frederick-vs-ja
Copy link
Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 14, 2021
Copy link
Member

@pwnall pwnall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution! I appreciate the explanation and the link to the C++23 paper.

Can you please add back the static_asserts? If CI still passes with them, I'd like to merge this.

util/no_destructor.h Outdated Show resolved Hide resolved
util/no_destructor.h Outdated Show resolved Hide resolved
util/no_destructor.h Show resolved Hide resolved
@marcushultman
Copy link

Any chance this can be picked up again?

@marcushultman
Copy link

@pwnall Would you mind re-reviewing this?

@frederick-vs-ja
Copy link
Author

frederick-vs-ja commented Feb 5, 2025

Most changes were superseded by commit 302786e.

@pwnall But I still think there're should be some pedantic changes:

  • in order to use the placement new-expression, we should include <new> to obtain the correct the operator new overload (which is unfortunately not implicitly declared);
  • as mentioned in the PR description, new should be prefixed with ::;
  • per CWG2489, char arrays don't provide storage for objects and we should use unsignd char arrays instead, although IIUC, compilers support such storage-providing mechanism as an extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants