/* * ======================================================== * * ZKA * Copyright (C) 2024, t& Corporation, all rights reserved., all rights reserved. * * ======================================================== */ #pragma once #include #include namespace Kernel { using ErrorT = UInt; template class ErrorOr final { public: ErrorOr() = default; ~ErrorOr() = default; public: explicit ErrorOr(Int32 err) : mId(err) { } explicit ErrorOr(nullPtr Null) { } explicit ErrorOr(T* Class) : mRef(Class) { } explicit ErrorOr(T Class) : mRef(Class) { } ErrorOr& operator=(const ErrorOr&) = default; ErrorOr(const ErrorOr&) = default; ErrorOr& operator=(const Ref& refErr) { mRef = refErr; return *this; } Ref& Leak() { return mRef; } Int32 Error() { return mId; } operator bool() { return mRef; } private: Ref mRef; Int32 mId{0}; }; using ErrorOrAny = ErrorOr; } // namespace Kernel