- More documentation

This commit is contained in:
2025-12-18 16:18:07 -05:00
parent 9e6f00eb60
commit 88e33bdcc8
50 changed files with 987 additions and 264 deletions

View File

@@ -135,6 +135,10 @@ public:
constexpr unique_ptr& operator=(const unique_ptr&) = delete;
///
/// \brief move constructor
/// \param r the pointer to take ownership of
/// \returns a reference to self
constexpr unique_ptr& operator=(unique_ptr&& r) noexcept {
_delete = r._delete;
_handle = r._handle;
@@ -142,13 +146,18 @@ public:
return *this;
}
///
/// \brief reset the pointer, destroying the held object
/// \param ptr the new pointer to own
void reset(pointer_t ptr) {
if(_handle) {
_delete(_handle);
_handle = ptr;
}
_handle = ptr;
}
///
/// \brief reset the pointer, destroying the held object
void reset(nullptr_t = nullptr) {
if(_handle) {
_delete(_handle);
@@ -156,28 +165,43 @@ public:
}
}
///
/// \brief releases the held pointer, returning it
/// \returns the released pointer
pointer_t release() {
pointer_t retval = _handle;
_handle = nullptr;
return retval;
}
///
/// \returns a reference to the held pointer
pointer_t get() const {
return _handle;
}
///
/// \returns \f$true\f$ if there is not a held pointer, \f$false\f$ otherwise
bool empty() {
return _handle == nullptr;
}
///
/// \returns the held object for access
pointer_t operator->() {
return _handle;
}
///
/// \brief access operator
/// \returns the held object for access
const_pointer_t operator->() const {
return _handle;
}
///
/// \brief implicit boolean conversion
/// \returns \f$true\f$ if there is a held pointer, \f$false\f$ otherwise
operator bool() const {
return _handle != nullptr;
}