From 9138ad691cce5f7aa0799fdd6c113a88402592ed Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 30 Sep 2019 03:13:05 -0400 Subject: [PATCH] FourCC: Make rest of interface noexcept where applicable Makes the interface consistent and allows their use within noexcept contexts. --- hecl/include/hecl/FourCC.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hecl/include/hecl/FourCC.hpp b/hecl/include/hecl/FourCC.hpp index 2b4c0c8d6..59af734cc 100644 --- a/hecl/include/hecl/FourCC.hpp +++ b/hecl/include/hecl/FourCC.hpp @@ -34,22 +34,22 @@ public: constexpr FourCC& operator=(const FourCC&) noexcept = default; constexpr FourCC& operator=(FourCC&&) noexcept = default; - constexpr bool operator==(const FourCC& other) const { return num == other.num; } - constexpr bool operator!=(const FourCC& other) const { return !operator==(other); } - constexpr bool operator==(const char* other) const { + constexpr bool operator==(const FourCC& other) const noexcept { return num == other.num; } + constexpr bool operator!=(const FourCC& other) const noexcept { return !operator==(other); } + constexpr bool operator==(const char* other) const noexcept { return other[0] == fcc[0] && other[1] == fcc[1] && other[2] == fcc[2] && other[3] == fcc[3]; } - constexpr bool operator!=(const char* other) const { return !operator==(other); } - constexpr bool operator==(int32_t other) const { return num == uint32_t(other); } - constexpr bool operator!=(int32_t other) const { return !operator==(other); } - constexpr bool operator==(uint32_t other) const { return num == other; } - constexpr bool operator!=(uint32_t other) const { return !operator==(other); } + constexpr bool operator!=(const char* other) const noexcept { return !operator==(other); } + constexpr bool operator==(int32_t other) const noexcept { return num == uint32_t(other); } + constexpr bool operator!=(int32_t other) const noexcept { return !operator==(other); } + constexpr bool operator==(uint32_t other) const noexcept { return num == other; } + constexpr bool operator!=(uint32_t other) const noexcept { return !operator==(other); } std::string toString() const { return std::string(std::begin(fcc), std::end(fcc)); } - constexpr uint32_t toUint32() const { return num; } - constexpr const char* getChars() const { return fcc; } - constexpr char* getChars() { return fcc; } - constexpr bool IsValid() const { return num != 0; } + constexpr uint32_t toUint32() const noexcept { return num; } + constexpr const char* getChars() const noexcept { return fcc; } + constexpr char* getChars() noexcept { return fcc; } + constexpr bool IsValid() const noexcept { return num != 0; } }; #define FOURCC(chars) FourCC(SBIG(chars))