Many languages have the concept that operations return a special type that can either be the desired output value or another type that represents an error. For example a function loadPlugin(String) would return Either<PluginObject, String> where String is an error message.
For C++ this is proposed as std::expected. However the standardization is not finalized and a (usable) resolution is years in the future.
Questions are:
- Do we want to apply this paradigm in our code?
- If yes, how is it going to be implemented?
- Use https://github.com/TartanLlama/expected, potentially wrapped in/renamed to KExpected in KCoreAddons. Advantage would be that we can start using it early
- Qt also expressed interest in having this, but that's a bit uncertain and material for 6.x
- Use custom struct solutions.