H'H H'H - 1 month ago 14
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>'


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(); }