From 5376236ab6b7a6706304f3669d273ce9340c5011 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 26 Nov 2024 00:55:12 +0200 Subject: [PATCH] BAN: Make ErrorOr non-copyable This makes avoiding accidentals copies easier :) --- BAN/include/BAN/Errors.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BAN/include/BAN/Errors.h b/BAN/include/BAN/Errors.h index 613deec507..49a23246ac 100644 --- a/BAN/include/BAN/Errors.h +++ b/BAN/include/BAN/Errors.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -97,6 +98,7 @@ namespace BAN template class [[nodiscard]] ErrorOr { + BAN_NON_COPYABLE(ErrorOr); public: ErrorOr(const T& value) : m_data(value) @@ -110,6 +112,14 @@ namespace BAN ErrorOr(Error&& error) : m_data(move(error)) {} + ErrorOr(ErrorOr&& other) + : m_data(move(other.m_data)) + {} + ErrorOr& operator=(ErrorOr&& other) + { + m_data = move(other.m_data); + return *this; + } bool is_error() const { return m_data.template has(); } const Error& error() const { return m_data.template get(); }