aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/common')
-rw-r--r--include/cru/common/Base.h22
-rw-r--r--include/cru/common/Event.h3
2 files changed, 20 insertions, 5 deletions
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 <cassert>
+#include <cstddef>
+#include <functional>
+#include <memory>
#ifdef CRU_PLATFORM_WINDOWS
#ifdef CRU_BASE_EXPORT_API
@@ -11,8 +16,6 @@
#define CRU_BASE_API
#endif
-#include <gsl/gsl>
-
#define CRU_UNUSED(entity) static_cast<void>(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 <typename T>
+inline void Expects(const std::shared_ptr<T>& ptr) {
+ assert(ptr != nullptr);
+}
+template <typename T>
+inline void Ensures(const std::shared_ptr<T>& ptr) {
+ assert(ptr != nullptr);
+}
// https://www.boost.org/doc/libs/1_54_0/doc/html/hash/reference.html#boost.hash_combine
template <class T>
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 <algorithm>
+#include <cassert>
#include <functional>
#include <memory>
#include <utility>
@@ -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_;
}