chsvlib
chsv helper source code

◆ AutoResource() [25/28]

AutoResource ( closer_rref  rrefCloser,
checker_rref  rrefChecker 
)

Constructs an AutoResource object from an rvalue of a closer and a checker to be used to close a managed handle and to check allowance for closing respectively. The handle is value-initialized.

Parameters
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.
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 created object is empty (owns nothing), with value-initialized stored handle.
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()).