From 30af6f0bfba176b326df0ac2d5090badf777edcf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 26 Oct 2019 21:33:39 -0400 Subject: [PATCH] CSegId: Make constexpr capable Allows the class to be used within constexpr contexts, given it's such a small class. --- Runtime/Character/CSegId.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Runtime/Character/CSegId.hpp b/Runtime/Character/CSegId.hpp index e351b7abd..589055190 100644 --- a/Runtime/Character/CSegId.hpp +++ b/Runtime/Character/CSegId.hpp @@ -3,26 +3,24 @@ #include "Runtime/IOStreams.hpp" #include "Runtime/RetroTypes.hpp" -#include - namespace urde { class CSegId { u8 x0_segId = 0xff; public: - CSegId() = default; - CSegId(u8 id) : x0_segId(id) {} - CSegId(CInputStream& in) : x0_segId(in.readUint32Big()) {} - CSegId& operator++() { + constexpr CSegId() noexcept = default; + constexpr CSegId(u8 id) noexcept : x0_segId(id) {} + explicit CSegId(CInputStream& in) : x0_segId(in.readUint32Big()) {} + constexpr CSegId& operator++() noexcept { ++x0_segId; return *this; } - CSegId& operator--() { + constexpr CSegId& operator--() noexcept { --x0_segId; return *this; } - operator u8() const { return x0_segId; } + constexpr operator u8() const noexcept { return x0_segId; } }; } // namespace urde