
Eric J. Holtman wrote:
I have some code that uses enable_shared_from_this.
I was publicly deriving, i.e. (and this works)
class Request : public boost::enable_shared_from_this<Request> { };
I wanted to change my code around so that I wrapped the shared_from_this function inside the class, so that I could check at runtime whether certain conditions hold, i.e.
class Request : private boost::enable_shared_from_this<Request> { public: boost::shared_ptr<Request> get_ptr () { if (conditions_are_good) return shared_from this (); else throw std::logic_error ("Bad get"); }; };
This won't compile (visual studio 2008).
One way to make it work is to add friend class boost::enable_shared_from_this<Request>; friend class boost::shared_ptr<Request>; to Request.