You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include <cstdio>
#include <cstdlib>
// replacement of a minimal set of functions:
void* operator new(std::size_t sz) {
std::printf("global op new called, size = %zu\n",sz);
return std::malloc(sz);
}
void operator delete(void* ptr) noexcept
{
std::puts("global op delete called");
std::free(ptr);
}
int main() {
int* p1 = new int;
delete p1;
int* p2 = new int[10]; // guaranteed to call the replacement in C++11
delete[] p2;
}
The text was updated successfully, but these errors were encountered:
Example from https://en.cppreference.com/w/cpp/memory/new/operator_delete
On godbolt: https://godbolt.org/z/cn1K68
On cppinsights: https://cppinsights.io/s/d7c759a7
The text was updated successfully, but these errors were encountered: