Talk:cpp/memory/new/operator new
From cppreference.com
< Talk:cpp
[edit] Naming Convention
The class specific definition of the new operator says "count" as a parameter:
Run this code
void* T::operator new ( std::size_t count );
However, the X structure example changes the name of the parameter to "sz" and uses it in "new(sz)".
Run this code
static void* operator new(std::size_t sz)
Alexis Wilke 20:46, 26 October 2021 (PDT)
- "sz" is the kind of Polish onomatopoeia that only 80s C programmers that get extraneous characters docked from the salary would use... Changed to "count". --Ybab321 (talk) 02:28, 27 October 2021 (PDT)
- I wrote the example and used "sz" as short for "size" (what does it mean in Polish?) --Cubbi (talk) 14:36, 28 October 2021 (PDT)
I believe that struct X code is missing []
Run this code
static void* operator new[](std::size_t count) { std::cout << "custom new[] for size " << count << '\n'; return ::operator new(count); // should be new[], right? }