Result: Add nonnull_or_error()
This commit is contained in:
parent
973e39a255
commit
3a3968b268
@ -202,3 +202,10 @@ template <> class Result<void>
|
||||
if (!_expr_rc.has_value()) return _expr_rc.release_error(); \
|
||||
_expr_rc.release_value(); \
|
||||
})
|
||||
|
||||
template <typename T> inline Result<T*> nonnull_or_error(T* ptr, int error)
|
||||
{
|
||||
if (ptr == nullptr) return err(error);
|
||||
else
|
||||
return ptr;
|
||||
}
|
Loading…
Reference in New Issue
Block a user