Boost logo

Boost Users :

From: Damien Hocking (damien_at_[hidden])
Date: 2007-12-06 16:22:27


All,

I'm replacing some standard C++ pointers with shared_ptrs. I've run
into a small problem using shared_ptr with a pointer to member.

With a really simple class:

class TestObject{
public:
    TestObject():value_(-5.4){}
    ~TestObject();
    double value_;
};

Trying this:

double TestObject::*dptr = 0;
shared_ptr<TestObject> testPtr =
    shared_ptr<TestObject>(new TestObject());

testPtr->*dptr = 5.7456;

On VS2005, I get an error on the ->*:

error C2296: '->*' : illegal, left operand has type 'boost::shared_ptr<T>'

This line is fine:

(*testPtr).*dptr = 5.7456;

Can anyone tell me why the compiler isn't converting
boost::shared_ptr<TestObject> to a TestObject* through
shared_ptr::operator-> ?
I can live with dereferencing the testPtr, but I'd like to understand
what's going on.

Damien


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net