Result: Add from_syscall()
This commit is contained in:
parent
cb67b41a39
commit
1c6fd95a70
@ -148,6 +148,13 @@ template <typename T> class Result
|
|||||||
return Error { error };
|
return Error { error };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result<T> from_syscall(long rc)
|
||||||
|
{
|
||||||
|
if (rc < 0) return Error { (int)-rc };
|
||||||
|
else
|
||||||
|
return (T)rc;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Option<T> m_value;
|
Option<T> m_value;
|
||||||
int m_error;
|
int m_error;
|
||||||
|
Loading…
Reference in New Issue
Block a user