
I've got some problem with the shared_ptr usage in my library. I am suspecting its in combination with boost::bind. What happens when a boost::function is called and has been created with a (method, instance) combination, but the instance no longer exists? What happens when this is in combination with boost::asio::io_service? Here is my suspect code: B::SharedPtr me = boost::dynamic_pointer_cast(shared_from_this()); callback = boost::bind(&B::Foo, me, boost::asio::placeholder::error); // this is a boost::asio::ip::tcp::acceptor acceptor.async_accept(socket_, callback); Now suppose I use a raw pointer instead. Now suppose the instance that just got bound was destroyed before the accept happened. What will be the result? I'd try to just type up a test myself, but this requires alot of foundation code.