Static Analysis Problem Type Reference
A class defines an operator but lacks a definition for a naturally related operator.
This error flags several kinds of irregular usage that makes a class awkward to use. For example, a class that defines an operator such as "greater than" should also provide a definition for a related operator such as "less than". While it is true that a user can always replace "x less than y" with "y greater than x", it is better to define a complete set of related operators. Similarly, a class that supports "+" and assignment ("=") should also support "+=".
This error is also emitted when a class defines its own "new" operator but does not also define its own "delete" or "new []" operator.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Definition |
The place where the class was defined |
#include <new>
class A
{
public:
void *
operator new(size_t size, void * allocator)
throw() {
return NULL;
}
};
int main(int argc, char **argv)
{
A *a = new (0) A();
return 0;
}