chsvlib
chsv helper source code

◆ AutoResource() [24/28]

AutoResource ( handle_rref  rrefHandle,
closer_lref  refCloser,
checker_rref  rrefChecker 
)

Constructs an AutoResource object from rvalues of a handle and a checker using move semantics and from an lvalue reference to a closer used to close the handle.

Parameters
rrefHandleis an rvalue reference to a resource handle which is to be owned and managed by the created object.
refCloseris an lvalue reference to a closer object to be used for closing handles owned and managed by the created instance of the AutoResource.
rrefCheckeris an rvalue reference to a checker object to be used to check if a managed handle is allowed to be closed by the closer.
Remarks
The object takes ownership of the handle, initializing its stored handle, closer and checker with the specified values.
The only handles closed are the ones which are allowed to be closed by the checker.
Warning
The checker callable object must not allow the closing of the default constructed handle (i.e. handle_type()).