shared_from_this causing bad_weak_ptr
I am trying to keep a list of connected clients in asio. I have adapted the chat server example from the docs ( http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/example/cpp03/chat/chat_server.cpp ) and here's the important part of what I ended up with: #include <iostream> #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/asio.hpp> #include <set> using boost::asio::ip::tcp; class tcp_connection; std::set<boost::shared_ptr<tcp_connection>> clients; void add_client(boost::shared_ptr<tcp_connection> client) { clients