M
Marcel Müller
AFAIK it is impossible to detect the original length of an array from
the object pointer.
class SomeClass
{ // ...
};
SomeClass* array = new SomeClass[10];
size_t length = get_length_of_array(array); // Impossible
But the runtime needs to keep track of the number of elements anyway, to
call the appropriate number of destructors at delete[]. Why does the
language not allow to access this internal field?
Marcel
the object pointer.
class SomeClass
{ // ...
};
SomeClass* array = new SomeClass[10];
size_t length = get_length_of_array(array); // Impossible
But the runtime needs to keep track of the number of elements anyway, to
call the appropriate number of destructors at delete[]. Why does the
language not allow to access this internal field?
Marcel