Opened 10 years ago
Closed 10 years ago
#6941 closed Bugs (invalid)
ASIO Daytime.3 example misuses enable_shared_from_this
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.49.0 | Severity: | Problem |
Keywords: | Cc: |
Description
In the documentation for the ASIO library, the Daytime.3 example has class tcp_connection inheriting from enable_shared_from_this, but then in "tcp_connection::create()" we have
return pointer( new tcp_connection....)
where pointer is a typedef for the shared_ptr type.
Perhaps:
return (new tcp_connection...).shared_from_this()
?
By the way, thanks for all the wonderful software!
Change History (3)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
My apologies.... I missed that point.
http://en.cppreference.com/w/cpp/memory/enable_shared_from_this
Also, it makes sense that the c'tor is private and the factory forces the construction of the shared pointer.
Thank you.
comment:3 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Replying to m_albert137@…:
That's illegal. shared_from_this only works after you've created the initial shared_ptr.