For constructing an Unexpected object from an error code. Unexpected objects are implicitly convertible to Expected object in the error state. Usage is as follows:
Synopsis
Declared in <folly/Expected.h>
template<class Error>
constexpr
Unexpected<std::decay<Error>::type>
makeUnexpected(Error&& err);
Description
enum class MyErrorCode { BAD_ERROR, WORSE_ERROR }; Expected<int, MyErrorCode> myAPI() { int i = // ...; return i ? makeExpected<MyErrorCode>(i) : makeUnexpected(MyErrorCode::BAD_ERROR); }
Return Value
An Unexpected holding a decayed copy of err.
Parameters
Name |
Description |
err |
The error value to wrap. |
Created with MrDocs