chsvlib
chsv helper source code

◆ AutoResource() [17/28]

AutoResource ( handle_lref  refHandle,
closer_rref  rrefCloser,
checker_lref  refChecker 
)

Constructs an AutoResource object from lvalue handle, rvalue closer and lvalue checker. The handle will be managed by the created object using the closer and the checker to close the handle and to get permission for it respectively.

Parameters
refHandleis an lvalue reference to a resource handle which is to be owned and managed by the created object.
rrefCloseris an rvalue reference to a closer object passed using move semantics and used for closing handles owned and managed by the created instance of the AutoResource.
refCheckeris an lvalue reference to a checker object to be used for checking if a handle managed by the instance of the AutoResource is allowed to be closed. The default class of checkers is a DefaultResourceHandleChecker.
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()).