How to write the operator new[] and operator delete[] here in the Class HeapTracked?

I came across this problem when I was reading More Effective C++. It's in Item 27. The class HeapTracked is used as a base class for the heap tracking function, in other words, for judging whether this object is created in heap or not. In the demo, operator new and operator delete is given. Then how to write operator new[] and operator delete[] accordingly?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class HeapTracked
{
public:
	class NotOnHeap : public exception{};
	HeapTracked();
	virtual ~HeapTracked() = 0;
	static void* operator new(size_t size)
	{
		void* p = ::operator new(size);
		addresses.insert(p);
		return p;
	}
	static void* operator new[](size_t size)
	{
		// ?
	}
	static void operator delete(void* p)
	{
		if (addresses.find(p) != addresses.end())
		{
			addresses.erase(p);
			::operator delete(p);
		}
		else
		{
			throw NotOnHeap();
		}
	}
	static void operator delete[](void* p)
	{
		// ?
	}
	bool isOnHeap() const
	{
		const void* raw = dynamic_cast<const void*>(this);
		return addresses.find(raw) != addresses.end();
	}

private:
	typedef const void* RawAddress;
	static set<RawAddress> addresses;
};
Topic archived. No new replies allowed.