chsvlib
chsv helper source code

◆ AutoResource() [12/28]

AutoResource ( handle_rref  rrefHandle,
checker_lref  refChecker 
)

Constructs an AutoResource object from the specified rvalue reference to a handle using move semantics and an lvalue reference to a checker object, with the value-initialized default closer.

Parameters
rrefHandleis an rvalue reference to a resource handle which is to be owned and managed by the created object.
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 and checker and value-initializing its stored closer.
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()).