Adds functions to take ownership from a unique ptr
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
64108448bc
commit
74ef6b5bdc
|
@ -36,6 +36,13 @@ namespace ArbUt {
|
|||
/// @brief Return whether the pointer is null or not.
|
||||
[[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; }
|
||||
|
||||
/// @brief Get the raw underlying pointer, and take ownership of it. This removes the existing pointer in here.
|
||||
inline T* nullable TakeOwnership() noexcept {
|
||||
auto raw = _raw;
|
||||
_raw = nullptr;
|
||||
return raw;
|
||||
}
|
||||
|
||||
/// @brief Get the raw underlying pointer.
|
||||
inline T* nullable GetValue() const noexcept { return _raw; }
|
||||
|
||||
|
|
|
@ -56,6 +56,16 @@ namespace ArbUt {
|
|||
/// @warning Note that this asserts that the underlying pointer is not null first, to prevent segfaults.
|
||||
inline T* non_null operator->() const noexcept { return _raw; }
|
||||
|
||||
/// @brief Get the raw underlying pointer, and take ownership of it. This removes the existing pointer in here.
|
||||
#if defined(__clang__)
|
||||
[[clang::no_sanitize("nullability-assign")]]
|
||||
#endif
|
||||
inline T* non_null
|
||||
TakeOwnership() noexcept {
|
||||
auto raw = _raw;
|
||||
_raw = nullptr;
|
||||
return raw;
|
||||
}
|
||||
/// @brief Get the raw underlying pointer.
|
||||
inline T* non_null GetRaw() const noexcept { return _raw; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue