From 4934a78aaa3e4ecb4c47a3c30370ada1b6259b31 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Wed, 24 Aug 2022 01:19:59 +0200 Subject: [PATCH] lib/error: Move definitions of constructors of ErrorOr<> inside class definition. --- src/lib/error.hpp | 48 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/src/lib/error.hpp b/src/lib/error.hpp index 4987cec..1d6099d 100644 --- a/src/lib/error.hpp +++ b/src/lib/error.hpp @@ -23,37 +23,31 @@ struct ErrorOr { uint8_t errorCode; T value; - ErrorOr(); - ErrorOr(T); - ErrorOr(bool, uint8_t); - ErrorOr(bool, uint8_t, T); + ErrorOr() { + this->isError = false; + this->errorCode = 0; + } + + ErrorOr(T value) { + this->isError = false; + this->errorCode = 0; + this->value = value; + } + + ErrorOr(bool isError, uint8_t errorCode) { + this->isError = isError; + this->errorCode = errorCode; + } + + ErrorOr(bool isError, uint8_t errorCode, T value) { + this->isError = isError; + this->errorCode = errorCode; + this->value = value; + } }; -template -ErrorOr::ErrorOr() { - this->isError = false; - this->errorCode = 0; -} -template -ErrorOr::ErrorOr(T value) { - this->isError = false; - this->errorCode = 0; - this->value = value; -} -template -ErrorOr::ErrorOr(bool isError, uint8_t errorCode) { - this->isError = isError; - this->errorCode = errorCode; -} - -template -ErrorOr::ErrorOr(bool isError, uint8_t errorCode, T value) { - this->isError = isError; - this->errorCode = errorCode; - this->value = value; -} namespace ErrorCodes { // These are all arbitrary values used to assign error codes to different