Result: Add from_syscall()

This commit is contained in:
apio 2023-04-07 10:56:49 +02:00
parent cb67b41a39
commit 1c6fd95a70
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -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;