From c7c9c62fd3813a6230a2af7fc8c9882baa426a7f Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Oct 2020 00:01:30 +0800 Subject: ... --- include/cru/common/Base.hpp | 13 +++++++++---- include/cru/common/Event.hpp | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'include/cru/common') diff --git a/include/cru/common/Base.hpp b/include/cru/common/Base.hpp index a5a9421d..560f83bb 100644 --- a/include/cru/common/Base.hpp +++ b/include/cru/common/Base.hpp @@ -1,8 +1,8 @@ #pragma once #include "PreConfig.hpp" +#include #include - #include #define CRU_UNUSED(entity) static_cast(entity); @@ -42,12 +42,17 @@ struct Interface { virtual ~Interface() = default; }; -[[noreturn]] inline void UnreachableCode() { - throw std::runtime_error("Unreachable code."); -} +[[noreturn]] inline void UnreachableCode() { std::terminate(); } using Index = gsl::index; +// https://www.boost.org/doc/libs/1_54_0/doc/html/hash/reference.html#boost.hash_combine +template +inline void hash_combine(std::size_t& s, const T& v) { + std::hash h; + s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2); +} + #define CRU_DEFINE_CLASS_LOG_TAG(tag) \ private: \ constexpr static std::u16string_view log_tag = tag; diff --git a/include/cru/common/Event.hpp b/include/cru/common/Event.hpp index 6417bc78..93ab9b7a 100644 --- a/include/cru/common/Event.hpp +++ b/include/cru/common/Event.hpp @@ -232,6 +232,10 @@ class EventRevokerListGuard { return *this; } + void Clear() { event_revoker_guard_list_.clear(); } + + bool IsEmpty() const { return event_revoker_guard_list_.empty(); } + private: std::vector event_revoker_guard_list_; }; -- cgit v1.2.3