mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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:
parent
62af7c4bdf
commit
56a6d7924e
Notes:
sideshowbarker
2024-07-18 18:29:26 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/56a6d7924ee Pull-request: https://github.com/SerenityOS/serenity/pull/6881 Reviewed-by: https://github.com/ADKaster
1 changed files with 9 additions and 3 deletions
12
AK/Result.h
12
AK/Result.h
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue