add Serenity-style ErrorOr<> type

BodgeMaster-unfinished
BodgeMaster 2022-06-27 04:46:22 +02:00
parent 89e7a89e88
commit 5ea835dbb5
2 changed files with 22 additions and 0 deletions

1
src/lib/error.cpp Normal file
View File

@ -0,0 +1 @@
#include "error.h++"

21
src/lib/error.h++ Normal file
View File

@ -0,0 +1,21 @@
#pragma once
template <typename T>
struct ErrorOr {
bool isError;
T value;
ErrorOr<T>();
ErrorOr<T>(T);
};
template <typename T>
ErrorOr<T>::ErrorOr() {
this->isError = false;
}
template <typename T>
ErrorOr<T>::ErrorOr(T value) {
this->isError = false;
this->value = value;
}