From f3af6c7e5b46f4209a4981e5d7be217368f40b15 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 8 Feb 2024 15:12:29 +0800 Subject: Get rid of GSL. --- include/cru/common/Base.h | 22 ++++++++++++++++++---- include/cru/common/Event.h | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'include/cru/common') diff --git a/include/cru/common/Base.h b/include/cru/common/Base.h index 34faf779..8a6a7634 100644 --- a/include/cru/common/Base.h +++ b/include/cru/common/Base.h @@ -1,5 +1,10 @@ #pragma once -#include "PreConfig.h" // IWYU pragma: keep +#include "PreConfig.h" // IWYU pragma: keep + +#include +#include +#include +#include #ifdef CRU_PLATFORM_WINDOWS #ifdef CRU_BASE_EXPORT_API @@ -11,8 +16,6 @@ #define CRU_BASE_API #endif -#include - #define CRU_UNUSED(entity) static_cast(entity); #define CRU__CONCAT(a, b) a##b @@ -83,7 +86,18 @@ struct CRU_BASE_API Interface { [[noreturn]] void CRU_BASE_API UnreachableCode(); -using Index = gsl::index; +using Index = std::ptrdiff_t; + +inline void Expects(bool condition) { assert(condition); } +inline void Ensures(bool condition) { assert(condition); } +template +inline void Expects(const std::shared_ptr& ptr) { + assert(ptr != nullptr); +} +template +inline void Ensures(const std::shared_ptr& ptr) { + assert(ptr != nullptr); +} // https://www.boost.org/doc/libs/1_54_0/doc/html/hash/reference.html#boost.hash_combine template diff --git a/include/cru/common/Event.h b/include/cru/common/Event.h index 14d68833..18d2c570 100644 --- a/include/cru/common/Event.h +++ b/include/cru/common/Event.h @@ -4,6 +4,7 @@ #include "SelfResolvable.h" #include +#include #include #include #include @@ -235,7 +236,7 @@ class EventRevokerGuard { EventRevoker Get() { // revoker is only null when this is moved // you shouldn't use a moved instance - Expects(revoker_); + assert(revoker_); return *revoker_; } -- cgit v1.2.3