Semantics of pointer dereference operator `->`
<p>I am looking for some help regarding the  pointer dereference operator <strong><code>-&gt;</code></strong> . Let me describe what I am trying to do.</p>

<p>I am implementing a unidirectional iterator for a special container. The container is special in the sense that it does not physically allocate any space for the contained values but generates them at run time on demand. For example, consider that the container is "<strong>M consecutive integral multiples of N</strong>".</p>

<p>Since I do not want to store the value directly in my iterator, I create a value on the heap on demand.</p>

<p>When I need a pointer to the value I delete the old one if it's out-of-date and create a new one.  This means that invocation of <strong><code>operator *()</code></strong> or <strong><code>operator -&gt;()</code></strong> may <code>delete</code> an old value and <code>new</code> a new value, if the iterator has been advanced with <code>operator ++()</code> after they were last invoked.</p>

<p>Now I would like to use a <strong><code>smart_ptr</code></strong> to point at my value rather than keep a native pointer around. In order to do so I realize I need to understand the semantics of the <strong><code>-&gt;</code></strong> operator better.</p>

<ul>
<li>First of all, is <strong><code>-&gt;</code></strong> a <strong>unary</strong> operator ?</li>
<li>If that be so, how does <strong><code>i-&gt;member</code></strong> work. This would translate to <code>(pointer returned)member</code>, which is not a syntactically  valid form.</li>
<li><strong>"member"</strong> could be a data member or a member function. </li>
<li><strong><code>-&gt;()</code></strong> smells more like a binary operator that executes <code>(*pointer returned).member</code>. Since "member" is not a value, such a semantics is not equivalent to a binary operator either.</li>
<li>What happens to the pointer returned by <code>-&gt;()</code> ? who is supposed to own it ?</li>
<li>How can I use RAAI in this framework ? Is reference counted pointers the only option ?</li>
<li>There is no <code>--</code> operator for this iterator so i don't need to keep the previous values around </li>
</ul>

<p>Thanks for your responses. Ending with a meta question, should this be a wiki ?</p>
