
4 Dec
2011
4 Dec
'11
10:11 p.m.
Scoped_array can not take a pointer in the middle of the allocated array as its role is to delete it.
Exactly.
True for scoped_array. As Olaf pointed out, it would be possible to have a custom deleter for shared_array that would allow shared_array to point to the middle of an allocation. Then it seems reasonable to have shared_array::operator[] take a ptrdiff_t. It'd be weird to have shared_array and scoped_array take different types for operator[]. ptrdiff_t for both seems fine to me and size_t is demonstrably wrong for shared_array in at least one (very goofy) use case. - Rhys