Why is this an issue?
Allocation functions are always static
. Explicitly declaring such a function static
needlessly clutters the code.
Noncompliant code example
struct S {
static void* operator new(std::size_t); // Noncompliant; static is redundant
static void operator delete(void*); // Noncompliant; static is redundant
};
Compliant solution
struct S {
void* operator new(std::size_t);
void operator delete(void*);
};
Resources
- Reference: Since C++98 (ISO IEC 14882 1998) 12.5 §1 and §6
Any allocation function for a class T is a static member (even if not explicitly declared static).
Any deallocation function for a class X is a static member (even if not explicitly declared static).