H'H H'H - 2 years ago 141
C++ Question

boost::thread_specific_ptr cannot access private member declared in class

I am wondering if there is a way to resolve following issue without changing the ptr access type.

class A
static boost::thread_specific_ptr< B> ptr;
boost::thread_specific_ptr< B> get() { return poolmanager_boost; }


boost::thread_specific_ptr<B>::thread_specific_ptr': cannot access private member declared in class 'boost::thread_specific_ptr<B>'

Answer Source

The boost::thread_specific_ptr is non-copyable and therefore cannot be returned by value. Either return a (const) reference to the member ptr:

const boost::thread_specific_ptr< B> & get() const { return ptr; }

Or return the contained pointer:

B * get() const { return ptr.get(); }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download