ゴミ箱
|
#include <handler_ptr.hpp>
Public Types | |
using | element_type = T |
The type of element this object stores. More... | |
using | handler_type = Handler |
The type of handler this object stores. More... | |
Public Member Functions | |
handler_ptr & | operator= (handler_ptr const &)=delete |
Copy assignment (disallowed). More... | |
~handler_ptr () | |
handler_ptr (handler_ptr &&other) | |
handler_ptr (handler_ptr const &other) | |
Copy constructor. More... | |
template<class... Args> | |
handler_ptr (Handler &&handler, Args &&...args) | |
template<class... Args> | |
handler_ptr (Handler const &handler, Args &&...args) | |
handler_type & | handler () const |
Returns a reference to the handler. More... | |
operator bool () const | |
Returns true if *this owns an object. More... | |
T * | get () const |
T & | operator* () const |
Return a reference to the owned object. More... | |
T * | operator-> () const |
Return a pointer to the owned object. More... | |
handler_type | release_handler () |
template<class... Args> | |
void | invoke (Args &&...args) |
A smart pointer container with associated completion handler.
This is a smart pointer that retains shared ownership of an object through a pointer. Memory is managed using the allocation and deallocation functions associated with a completion handler, which is also stored in the object. The managed object is destroyed and its memory deallocated when one of the following happens:
Objects of this type are used in the implementation of composed operations. Typically the composed operation's shared state is managed by the handler_ptr and an allocator associated with the final handler is used to create the managed object.
T | The type of the owned object. |
Handler | The type of the completion handler. |
using boost::beast::handler_ptr< T, Handler >::element_type = T |
The type of element this object stores.
using boost::beast::handler_ptr< T, Handler >::handler_type = Handler |
The type of handler this object stores.
boost::beast::handler_ptr< T, Handler >::~handler_ptr | ( | ) |
Destructs the owned object if no more handler_ptr link to it.
If *this
owns an object and it is the last handler_ptr owning it, the object is destroyed and the memory deallocated using the associated deallocator.
boost::beast::handler_ptr< T, Handler >::handler_ptr | ( | handler_ptr< T, Handler > && | other | ) |
Move constructor.
When this call returns, the moved-from container will have no owned object.
boost::beast::handler_ptr< T, Handler >::handler_ptr | ( | handler_ptr< T, Handler > const & | other | ) |
Copy constructor.
boost::beast::handler_ptr< T, Handler >::handler_ptr | ( | Handler && | handler, |
Args &&... | args | ||
) |
Construct a new handler_ptr
This creates a new handler_ptr with an owned object of type T
. The allocator associated with the handler will be used to allocate memory for the owned object. The constructor for the owned object will be called thusly:
handler | The handler to associate with the owned object. The argument will be moved. |
args | Optional arguments forwarded to the owned object's constructor. |
boost::beast::handler_ptr< T, Handler >::handler_ptr | ( | Handler const & | handler, |
Args &&... | args | ||
) |
Construct a new handler_ptr
This creates a new handler_ptr with an owned object of type T
. The allocator associated with the handler will be used to allocate memory for the owned object. The constructor for the owned object will be called thusly:
handler | The handler to associate with the owned object. The argument will be copied. |
args | Optional arguments forwarded to the owned object's constructor. |
|
inline |
Returns a pointer to the owned object.
If *this
owns an object, a pointer to the object is returned, else nullptr
is returned.
|
inline |
Returns a reference to the handler.
void boost::beast::handler_ptr< T, Handler >::invoke | ( | Args &&... | args | ) |
Invoke the handler in the owned object.
This function invokes the handler in the owned object with a forwarded argument list. Before the invocation, the owned object is destroyed, satisfying the deallocation-before-invocation Asio guarantee. All instances of handler_ptr which refer to the same owned object will be reset, including this instance.
|
inlineexplicit |
Returns true
if *this
owns an object.
|
inline |
Return a reference to the owned object.
|
inline |
Return a pointer to the owned object.
|
delete |
Copy assignment (disallowed).
auto boost::beast::handler_ptr< T, Handler >::release_handler | ( | ) |
Release ownership of the handler
If *this
owns an object, it is first destroyed.