diff options
Diffstat (limited to 'include/cru/common')
-rw-r--r-- | include/cru/common/Base.hpp | 13 | ||||
-rw-r--r-- | include/cru/common/Event.hpp | 4 |
2 files changed, 13 insertions, 4 deletions
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 <exception> #include <gsl/gsl> - #include <stdexcept> #define CRU_UNUSED(entity) static_cast<void>(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 <class T> +inline void hash_combine(std::size_t& s, const T& v) { + std::hash<T> 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<EventRevokerGuard> event_revoker_guard_list_; }; |