Accessing array of shared_ptr
The bracket notation is defined to work with pointer types (and you're right that, given array array
, the expression array
decays to an expression with such a type which points to the first element) but, despite its function, std::shared_ptr
is not a pointer type.
You would have to obtain the raw pointer first:
array.get()[n];
Where n
is, of course, a valid array subscript.
This is also the case with std::unique_ptr
(though note that, in that case, you do not need to supply your own deleter!).