From 5ea835dbb502b2550f43b25e7c2883f524f3c3c5 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Mon, 27 Jun 2022 04:46:22 +0200 Subject: [PATCH] add Serenity-style ErrorOr<> type --- src/lib/error.cpp | 1 + src/lib/error.h++ | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/lib/error.cpp create mode 100644 src/lib/error.h++ diff --git a/src/lib/error.cpp b/src/lib/error.cpp new file mode 100644 index 0000000..23c28ff --- /dev/null +++ b/src/lib/error.cpp @@ -0,0 +1 @@ +#include "error.h++" diff --git a/src/lib/error.h++ b/src/lib/error.h++ new file mode 100644 index 0000000..b2d5569 --- /dev/null +++ b/src/lib/error.h++ @@ -0,0 +1,21 @@ +#pragma once + +template +struct ErrorOr { + bool isError; + T value; + + ErrorOr(); + ErrorOr(T); +}; + +template +ErrorOr::ErrorOr() { + this->isError = false; +} + +template +ErrorOr::ErrorOr(T value) { + this->isError = false; + this->value = value; +}