Skip to content

Provide a minimal new.h for CTL #1205

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

Merged
merged 1 commit into from
Jun 8, 2024
Merged

Provide a minimal new.h for CTL #1205

merged 1 commit into from
Jun 8, 2024

Conversation

mrdomino
Copy link
Collaborator

@mrdomino mrdomino commented Jun 8, 2024

This replaces the STL <new> header. Mainly, it defines a global operator new and operator delete, as well as the placement versions of these. The placement versions are required to not get compile errors when trying to write a placement new statement.

Each of these operators is defined with many, many different variants. A glance at new.cc is recommended followed by a chaser of the Alexandrescu talk "std::allocator is to Allocation as std::vector is to Vexation". We must provide a global-namespace source-level definition of each operator and it is illegal for any of them to be marked inline, so here we are.

The upshot is that we no longer need to include <new>, and our optional/ vector headers are self-contained.

This replaces the STL <new> header. Mainly, it defines a global operator
new and operator delete, as well as the placement versions of these. The
placement versions are required to not get compile errors when trying to
write a placement new statement.

Each of these operators is defined with many, many different variants. A
glance at new.cc is recommended followed by a chaser of the Alexandrescu
talk "std::allocator is to Allocation as std::vector is to Vexation". We
must provide a global-namespace source-level definition of each operator
and it is illegal for any of them to be marked inline, so here we are.

The upshot is that we no longer need to include <new>, and our optional/
vector headers are self-contained.
@mrdomino mrdomino requested a review from jart June 8, 2024 21:44
@mrdomino mrdomino merged commit cfec787 into jart:master Jun 8, 2024
@mrdomino mrdomino deleted the ctl-new branch June 8, 2024 22:04
@mrdomino mrdomino restored the ctl-new branch June 8, 2024 22:05
mrdomino added a commit that referenced this pull request Jun 8, 2024
This replaces the STL <new> header. Mainly, it defines a global operator
new and operator delete, as well as the placement versions of these. The
placement versions are required to not get compile errors when trying to
write a placement new statement.

Each of these operators is defined with many, many different variants. A
glance at new.cc is recommended followed by a chaser of the Alexandrescu
talk "std::allocator is to Allocation as std::vector is to Vexation". We
must provide a global-namespace source-level definition of each operator
and it is illegal for any of them to be marked inline, so here we are.

The upshot is that we no longer need to include <new>, and our optional/
vector headers are self-contained.
@mrdomino mrdomino deleted the ctl-new branch June 8, 2024 22:05
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.

2 participants