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