[#bsl-shared_ptr-0a-operator_subs]
= xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]::operator&lsqb;&rsqb;
:relfileprefix: ../../
:mrdocs:

Return a reference to the element at the specified `index`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;sharedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
add&lowbar;lvalue&lowbar;reference&lt;element&lowbar;type&gt;::type
operator&lsqb;&rsqb;(ptrdiff&lowbar;t index) const;
----

== Description

Return a reference providing modifiable access to the object at the specified `index` offset in the object referred to by this shared pointer&period; The behavior is undefined unless this shared pointer is not empty, `ELEMENT&lowbar;TYPE` is not `void` (a compiler error will be generated if this operator is instantiated within the `shared&lowbar;ptr&lt;void&gt;` class), and this shared pointer refers to an array of `ELEMENT&lowbar;TYPE` objects&period; Instead of `element&lowbar;type &amp;`, we use `add&lowbar;lvalue&lowbar;reference&lt;element&lowbar;type&gt;&colon;&colon;type` for the return type because that allows people to instantiate `shared&lowbar;ptr&lt;cv&lowbar;void&gt;`, as long as they don&apos;t use this method&period; Note that this method is logically equivalent to `&ast;(get() &plus; index)`&period;

== Return Value

reference providing modifiable access to the element at `index`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *index*
| zero&hyphen;based index into the referenced array
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
