AK: Let ErrorOr<T, E> expose its result/error types

`ErrorOr<T, E>::ResultType` can now refer to `T`.
This commit is contained in:
Ali Mohammad Pur 2022-12-10 15:29:20 +03:30 committed by Ali Mohammad Pur
commit 537924a8d0
Notes: sideshowbarker 2024-07-17 20:58:35 +09:00

View file

@ -72,9 +72,12 @@ private:
bool m_syscall { false }; bool m_syscall { false };
}; };
template<typename T, typename ErrorType> template<typename T, typename E>
class [[nodiscard]] ErrorOr { class [[nodiscard]] ErrorOr {
public: public:
using ResultType = T;
using ErrorType = E;
ErrorOr() ErrorOr()
requires(IsSame<T, Empty>) requires(IsSame<T, Empty>)
: m_value_or_error(Empty {}) : m_value_or_error(Empty {})
@ -146,6 +149,7 @@ private:
template<typename ErrorType> template<typename ErrorType>
class [[nodiscard]] ErrorOr<void, ErrorType> : public ErrorOr<Empty, ErrorType> { class [[nodiscard]] ErrorOr<void, ErrorType> : public ErrorOr<Empty, ErrorType> {
public: public:
using ResultType = void;
using ErrorOr<Empty, ErrorType>::ErrorOr; using ErrorOr<Empty, ErrorType>::ErrorOr;
}; };