For constructing an Expected object from a value, with the specified Error type. Usage is as follows:
Declared in <folly/Expected.h>
template<
class Error,
class Value>
[[nodiscard]]
constexpr
Expected<std::decay<Value>::type, Error>
makeExpected(Value&& val);
enum MyErrorCode { BAD_ERROR, WORSE_ERROR }; Expected<int, MyErrorCode> myAPI() { int i = // ...; return i ? makeExpected<MyErrorCode>(i) : makeUnexpected(BAD_ERROR); }
An Expected in the value state holding a decayed copy of val.
The return value should not be discarded.
| Name | Description |
|---|---|
| val | The value to wrap. |