AK: Let Result<T, E> know its Value and Error types

It's much easier to ask for T::ValueType than for
RemoveReference<decltype(declval<T>().release_value())>
This commit is contained in:
Ali Mohammad Pur 2021-04-27 16:16:44 +04:30 committed by Andreas Kling
parent 62af7c4bdf
commit 56a6d7924e
Notes: sideshowbarker 2024-07-18 18:29:26 +09:00

View file

@ -11,9 +11,12 @@
namespace AK {
template<typename ValueType, typename ErrorType>
template<typename ValueT, typename ErrorT>
class [[nodiscard]] Result {
public:
using ValueType = ValueT;
using ErrorType = ErrorT;
Result(const ValueType& res)
: m_result(res)
{
@ -69,9 +72,12 @@ private:
};
// Partial specialization for void value type
template<typename ErrorType>
class [[nodiscard]] Result<void, ErrorType> {
template<typename ErrorT>
class [[nodiscard]] Result<void, ErrorT> {
public:
using ValueType = void;
using ErrorType = ErrorT;
Result(const ErrorType& error)
: m_error(error)
{