[Boost-bugs] [Boost C++ Libraries] #5686: Member function and member variable pointers don't work well with shared_ptr

Subject: [Boost-bugs] [Boost C++ Libraries] #5686: Member function and member variable pointers don't work well with shared_ptr
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-07-11 23:24:58


#5686: Member function and member variable pointers don't work well with
shared_ptr
------------------------------------------+---------------------------------
 Reporter: patvarilly@… | Owner: pdimov
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
  Version: Boost 1.45.0 | Severity: Problem
 Keywords: shared_ptr pointer-to-member |
------------------------------------------+---------------------------------
 The current implementation of shared_ptr doesn't overload operator->*, 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-> implementation. Here's an example of what doesn't
 work but should:

 {{{
 #!cpp
 class A
 {
 public: int memberA;
 }

 ...
 int A::*memberVariablePtr = &A::memberA;
 shared_ptr<A> ASharedPtr( ... );

 // The following two pieces of code should be functionally identical

 // 1) Doesn't compile. Error in g++: "base operand of -> is not a
 pointer"
 // It took me a while to figure out what g++ was complaining about
 int val = ASharedPtr->*memberVariablePtr;

 // 2) Compiles and works just fine
 int val = ASharedPtr.get()->*memberVariablePtr;
 }}}

 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5686>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC