aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/ClonablePtr.hpp48
-rw-r--r--include/cru/common/Event.hpp1
-rw-r--r--include/cru/platform/HeapDebug.hpp7
3 files changed, 30 insertions, 26 deletions
diff --git a/include/cru/common/ClonablePtr.hpp b/include/cru/common/ClonablePtr.hpp
index 5e4b80c9..39b5b454 100644
--- a/include/cru/common/ClonablePtr.hpp
+++ b/include/cru/common/ClonablePtr.hpp
@@ -93,6 +93,18 @@ class ClonablePtr {
element_type& operator*() const noexcept { return *ptr_; }
pointer operator->() const noexcept { return ptr_.get(); }
+ int Compare(const ClonablePtr& other) const noexcept {
+ if (ptr_ == other.ptr_) {
+ return 0;
+ } else if (ptr_ < other.ptr_) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ int Compare(nullptr_t) const noexcept { return ptr_ ? 1 : 0; }
+
private:
std::unique_ptr<element_type> ptr_;
};
@@ -104,92 +116,92 @@ void swap(ClonablePtr<T>& left, ClonablePtr<T>& right) noexcept {
template <typename T>
bool operator==(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() == right.get();
+ return left.Compare(right) == 0;
}
template <typename T>
bool operator!=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() != right.get();
+ return left.Compare(right) != 0;
}
template <typename T>
bool operator<(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() < right.get();
+ return left.Compare(right) < 0;
}
template <typename T>
bool operator<=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() <= right.get();
+ return left.Compare(right) <= 0;
}
template <typename T>
bool operator>(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() > right.get();
+ return left.Compare(right) > 0;
}
template <typename T>
bool operator>=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() >= right.get();
+ return left.Compare(right) >= 0;
}
template <typename T>
bool operator==(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() == nullptr;
+ return left.Compare(nullptr) == 0;
}
template <typename T>
bool operator!=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() != nullptr;
+ return left.Compare(nullptr) != 0;
}
template <typename T>
bool operator<(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() < nullptr;
+ return left.Compare(nullptr) < 0;
}
template <typename T>
bool operator<=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() <= nullptr;
+ return left.Compare(nullptr) <= 0;
}
template <typename T>
bool operator>(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() > nullptr;
+ return left.Compare(nullptr) > 0;
}
template <typename T>
bool operator>=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() >= nullptr;
+ return left.Compare(nullptr) >= 0;
}
template <typename T>
bool operator==(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr == right.get();
+ return right.Compare(nullptr) == 0;
}
template <typename T>
bool operator!=(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr != right.get();
+ return right.Compare(nullptr) != 0;
}
template <typename T>
bool operator<(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr < right.get();
+ return right.Compare(nullptr) > 0;
}
template <typename T>
bool operator<=(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr <= right.get();
+ return right.Compare(nullptr) >= 0;
}
template <typename T>
bool operator>(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr > right.get();
+ return right.Compare(nullptr) < 0;
}
template <typename T>
bool operator>=(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr >= right.get();
+ return right.Compare(nullptr) <= 0;
}
} // namespace cru
diff --git a/include/cru/common/Event.hpp b/include/cru/common/Event.hpp
index b6999aa4..5d60c5b3 100644
--- a/include/cru/common/Event.hpp
+++ b/include/cru/common/Event.hpp
@@ -8,7 +8,6 @@
#include <initializer_list>
#include <memory>
#include <utility>
-#include <variant>
#include <vector>
namespace cru {
diff --git a/include/cru/platform/HeapDebug.hpp b/include/cru/platform/HeapDebug.hpp
deleted file mode 100644
index 10ebfd2c..00000000
--- a/include/cru/platform/HeapDebug.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-#include "cru/common/PreConfig.hpp"
-
-namespace cru::platform {
-// Setup the heap debug function. Currently I only use this on Windows...
-void SetupHeapDebug();
-} // namespace cru::platform