boost - adding a shared_ptr object on a weak_ptr container -


my class based on boost::asio tutorial.

this class has private ctor, derived enable_shared_from_this.

its static member function return shared_ptr object created.

i want store pointers on list of weak_ptr, list don't need worry life time, either prolong it.

the caller tcp_serve instantiate tcp_connection create method:

tcp_server:

        tcp_connection::pointer new_connection =     tcp_connection::create(acceptor_.get_io_service()); 

tcp_connection:

public: typedef boost::shared_ptr<tcp_connection> pointer;  static pointer create(boost::asio::io_service& io_service) {     return pointer(new tcp_connection(io_service)); }  private: tcp_connection(boost::asio::io_service& io_service) : _socket(io_service), _timer(io_service) { } 

i trying create list on tcp_server, tried many different kind of types, can't rightly added object list:

    std::list<std::weak_ptr<tcp_connection>> connections;     connections.push_back(new_connection); 


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -