From 8753d39b667db421e93d545ff81607bb66f90298 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 16 Apr 2020 22:19:27 -0500 Subject: [PATCH] [ox/std] Fix OxError for release builds and fix ox::Error assignment operator --- deps/ox/src/ox/std/error.hpp | 18 +++++++++++------- deps/ox/src/ox/std/strongint.hpp | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 2398e6339..b6aee015b 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -8,15 +8,12 @@ #pragma once +#include "defines.hpp" #include "strongint.hpp" #include "typetraits.hpp" #include "utility.hpp" -#ifdef DEBUG #define OxError(...) ox::_error(__FILE__, __LINE__, __VA_ARGS__) -#else -#define OxError(...) static_cast(__VA_ARGS__) -#endif namespace ox { @@ -33,15 +30,22 @@ struct BaseError { line = o.line; } + constexpr BaseError operator=(const BaseError &o) noexcept { + msg = o.msg; + file = o.file; + line = o.line; + return *this; + } + }; using Error = Integer; static constexpr Error _error(const char *file, uint32_t line, uint64_t errCode, const char *msg = nullptr) { Error err = static_cast(errCode); - err.file = file; - err.line = line; - err.msg = msg; + err.file = file; + err.line = line; + err.msg = msg; return err; } diff --git a/deps/ox/src/ox/std/strongint.hpp b/deps/ox/src/ox/std/strongint.hpp index 9da34ec97..72a6b7225 100644 --- a/deps/ox/src/ox/std/strongint.hpp +++ b/deps/ox/src/ox/std/strongint.hpp @@ -12,13 +12,24 @@ namespace ox { -class BaseInteger {}; +struct BaseInteger { + + constexpr BaseInteger() = default; + + constexpr BaseInteger(const BaseInteger&) { + } + + constexpr BaseInteger operator=(const BaseInteger&) { + return *this; + } + +}; /** * Integer is a strongly typed integer wrapper used to create strongly typed * integers. */ -template +template class Integer: public Base { private: T m_i; @@ -115,7 +126,9 @@ constexpr Integer::Integer(const Integer &i) noexcept: Base(i) template constexpr Integer Integer::operator=(Integer i) noexcept { - return Integer(m_i = i.m_i); + Base::operator=(i); + m_i = i.m_i; + return *this; } template