Provide a minimal new.h for CTL (#1205)

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 commit is contained in:
Jōshin 2024-06-08 14:30:58 -07:00
parent a0410f0170
commit 118db71121
No known key found for this signature in database
6 changed files with 152 additions and 4 deletions

View file

@ -18,10 +18,10 @@
#include "ctl/optional.h"
#include <new>
#include "ctl/string.h"
#include "libc/runtime/runtime.h"
// #include <optional>
// #include <string>
// #define ctl std