Determining the number of objects allocated to a pointer...
Is there an operator ( similar to sizeof() ) that will tell how many objects have been allocated in memory using "new" to a pointer? In other words:
The reason for this is that I am writing wrapper functions for "new" and "delete." It is easy to tell how many objects are being allocated (since that's a parameter to new), but I am trying to determine how to tell how many are being deleted with delete.
int * foo = new int;
int bar = some_operator(foo);
// bar should be 50
//(or 200 if it referred to bytes, assuming 4-byte ints)
// Either of these would be helpful.
Also, "delete" is typically used to deallocate a single object, while "delete" deallocates an array. Is it harmful to call "delete" on a single object (not an array, or an array of one, if you will)? Along similar lines, is it acceptable to allocate with "new" instead of just "new"?