resource: add ::reset functions (with tests)

This commit is contained in:
Michele Caini
2024-04-12 11:17:57 +02:00
parent 0b6e325109
commit aa178dd2cf
2 changed files with 25 additions and 0 deletions

View File

@@ -148,6 +148,19 @@ public:
return static_cast<bool>(value);
}
/*! @brief Releases the ownership of the managed resource. */
void reset() {
value.reset();
}
/**
* @brief Replaces the managed resource.
* @param other A handle to a resource.
*/
void reset(handle_type other) {
value = std::move(other);
}
/**
* @brief Returns the underlying resource handle.
* @return The underlying resource handle.