Namespaces
Variants
Views
Actions

Talk:cpp/memory/new/operator new

From cppreference.com

[edit] Naming Convention

The class specific definition of the new operator says "count" as a parameter:

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)".

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 was just trying to be funny, it's just a common digraph in Polish where it sounds like "sh", which the onomatopoeia for telling someone to be quiet --Ybab321 (talk) 02:03, 29 October 2021 (PDT)

I believe that struct X code is missing []

static void* operator new[](std::size_t count)
    {
        std::cout << "custom new[] for size " << count << '\n';
        return ::operator new(count); // should be new[], right?
    }

188.198.16.19

I agree, fixed --Ybab321 (talk) 07:11, 1 April 2022 (PDT)