Boost C++ Libraries: Ticket #5686: Member function and member variable pointers don't work well with shared_ptr https://svn.boost.org/trac10/ticket/5686 <p> The current implementation of shared_ptr doesn't overload operator-&gt;*, so member function and member variable pointers don't play nicely with shared_ptrs. I would imagine that this is trivial to fix given the existing operator-&gt; implementation. Here's an example of what doesn't work but should: </p> <div class="wiki-code"><div class="code"><pre><span class="k">class</span> <span class="nc">A</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="kt">int</span> <span class="n">memberA</span><span class="p">;</span> <span class="p">}</span> <span class="p">...</span> <span class="kt">int</span> <span class="n">A</span><span class="o">::*</span><span class="n">memberVariablePtr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">A</span><span class="o">::</span><span class="n">memberA</span><span class="p">;</span> <span class="n">shared_ptr</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span> <span class="n">ASharedPtr</span><span class="p">(</span> <span class="p">...</span> <span class="p">);</span> <span class="c1">// The following two pieces of code should be functionally identical</span> <span class="c1">// 1) Doesn&#39;t compile. Error in g++: &quot;base operand of -&gt; is not a pointer&quot;</span> <span class="c1">// It took me a while to figure out what g++ was complaining about</span> <span class="kt">int</span> <span class="n">val</span> <span class="o">=</span> <span class="n">ASharedPtr</span><span class="o">-&gt;*</span><span class="n">memberVariablePtr</span><span class="p">;</span> <span class="c1">// 2) Compiles and works just fine</span> <span class="kt">int</span> <span class="n">val</span> <span class="o">=</span> <span class="n">ASharedPtr</span><span class="p">.</span><span class="n">get</span><span class="p">()</span><span class="o">-&gt;*</span><span class="n">memberVariablePtr</span><span class="p">;</span> </pre></div></div><p> Note: I tried this with version 1.45.0, but looked up the documentation of shared_ptr in 1.46.1 to make sure that this hasn't already been addressed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5686 Trac 1.4.3 Peter Dimov Wed, 11 Dec 2013 17:16:08 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5686#comment:1 https://svn.boost.org/trac10/ticket/5686#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket