Utils::Result Class | Extending Qt Creator Manual
Description: Result<T> is used for returning either a success value or an error string from a function.

- Extending Qt Creator Manual
- QtCreator
- Result
- Extending Qt Creator Manual 18.0.2

# Utils::Result Class

template <typename T = void> class Utils::Result

Result<T> is used for returning either a success value or an error string from a function. More...

Header: | `#include <Result>`

## Detailed Description

The Result typedef is a shorthand for `expected<T, QString>`, with the expected value of type `T` being returned in the success case, and the unexpected value being an error message for the user.

Use `Result<>` as the type when you do not have a concrete success value to return (do not use `Result<bool>`). In that case, return Utils::ResultOk to return success. You can also use the convenience function Utils::makeResult to combine the success and error cases.

Return a Utils::ResultError value as a convenience class for the error case.

See also Utils::ResultOk, Utils::ResultError, and Utils::makeResult.