<p>The topic generically says it all. Basically in a situation like this:</p>

<pre><code>boost::scoped_array&lt;int&gt; p(new int[10]);
</code></pre>

<p>Is there any appreciable difference in performance between doing: <code>&amp;p[0]</code> and <code>p.get()</code>?</p>

<p>I ask because I prefer the first one, it has a more natural pointer like syntax. In fact, it makes it so you could replace p with a native pointer or array and not have to change anything else.</p>

<p>I am guessing since get is a one liner "<code>return ptr;</code>" that the compiler will inline that, and I hope that it is smart enough to to inline <code>operator[]</code> in such a way that it is able to not dereference and then immediately reference.</p>

<p>Anyone know?</p>

The only way to know is to actually measure it!
But if you have the source of the boost:scoped_array you could llok at the code and see what it does. I am sure it is pretty similar.
```
```
T * scoped_array::get() const // never throws
{
    return ptr;
}

T & scoped_array::operator[](std::ptrdiff_t i) const // never throws
{
    BOOST_ASSERT(ptr != 0);
    BOOST_ASSERT(i >= 0);
    return ptr[i];
}
```
```
Write two versions of the code (one using get() the other using operator[]). Compile to assembley with optimizations turned on. See if your compiler actually manages to optimize away the ptr+0.