Failure to overload operator delete

This is a discussion on Failure to overload operator delete within the C++ Programming forums, part of the General Programming Boards category; I seem to be missing something. I'm failing to overload the delete operator for a class.
Code:
template < typename ...

I can see what your idea is. I think you would have to make a pointer of the class itself to make this work. You may be able to hide this by using either macros or clever template programming (I can think of how you MAY be able to do it with macros, not at all convinced templates are able to do this).

1) new and delete are implicitly static, whether you add the keyword or not.

2) new and delete are you used when you allocate/delete an object of that class type. Obviously, for delete, that means using delete with a pointer to that type.

You cannot overload delete in a way that allows you to pass a plain object to it. You'll have to create a member function for that and call it the normal way. You cannot emulate pointer syntax here. Since it was expected that smart pointers (which is what the whole pointer syntax stuff was itnroduced for) would automatically delete objects, this was not seen as necessary.

Edit: Seems you actually found a trick to do this. Just be aware that this means you can't actually allocate a DeleteChecker on the heap.

I know it will create all sorts of problem, but it wasn't meant to put on the heap anyway. I may as well disable the new operator to prevent disaster.
We'll see how this turns out

UPDATE:
It seems everything does not work as it should.
In fact... oh dear... it calls the destructor for debug_ptr FIRST and THEN operator delete!
Oh no. This is not how it was supposed to work.

Well, that's what I'd expect, since you can't actually delete something FIRST, then destroy it, can you? So your destructor would have to do the "accounting" (and actual deleting of the object itself?), then let the delete operator just do what it needs to do [de-allocate, mainly].

[Work in progress, and not the original code that was in the destructor. As you can see, it also has some bugs, too, which I haven't worked on correcting yet.]
The problem would be that the reference count == 1 and it would error.
The idea is that is the reference count == 1 and the object goes out of scope, that would mean a memory leak since it's the hold pointer holding the data.

I'm thinking of encapsulating the pointer in another class, so that it isn't affected by the destructor.

I personally woudl override the global new/delete operators, and just allocate an extra block of memory to hold some admin data to detect the memory leaks (such as a linked list of the line/file/func and size of the allocation). When the application finishes, you can check the linked list to see if it's got anything left that shouldn't be there, and list that to a file or some such.