[Boost-bugs] [Boost C++ Libraries] #7962: shared_ptr of chat_server.cpp

Subject: [Boost-bugs] [Boost C++ Libraries] #7962: shared_ptr of chat_server.cpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-01 19:27:59


#7962: shared_ptr of chat_server.cpp
------------------------------------------------+---------------------------
 Reporter: Shiwei Weng <wengshiwei@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: Boost 1.53.0 | Component: asio
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: |
------------------------------------------------+---------------------------
 In the example file
 "[http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/chat/chat_server.cpp
 chat_server.cpp]"
 http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/chat/chat_server.cpp

 In the for-loop in the main:
   chat_server_ptr server(new chat_server(io_service, endpoint));
 while
   typedef boost::shared_ptr<chat_server> chat_server_ptr;

 Since a shared_ptr is used to manage chat_server, class chat_server should
 inherit public boost::enable_shared_from_this<chat_server>, just as class
 chat_session does.

 Or in the member function start_accept() of class chat_server:
   acceptor_.async_accept(
     new_session->socket(),
     boost::bind(&chat_server::handle_accept, this, new_session,
       boost::asio::placeholders::error));

 The appearance of "this" seems problematic.

 Thanks for reading.
 Shiwei Weng

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7962>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC