Adds functions to take ownership from a unique ptr
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		| @@ -36,6 +36,13 @@ namespace ArbUt { | |||||||
|         /// @brief Return whether the pointer is null or not. |         /// @brief Return whether the pointer is null or not. | ||||||
|         [[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; } |         [[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. |         /// @brief Get the raw underlying pointer. | ||||||
|         inline T* nullable GetValue() const noexcept { return _raw; } |         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. |         /// @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; } |         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. |         /// @brief Get the raw underlying pointer. | ||||||
|         inline T* non_null GetRaw() const noexcept { return _raw; } |         inline T* non_null GetRaw() const noexcept { return _raw; } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user