diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-06-12 23:57:24 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-06-12 23:57:24 +0200 |
commit | 8279acc1a4754bedaad0ba8bf00541c7b2a043e9 (patch) | |
tree | 586a05c6b4e2338d621d78d9107090d5b587c683 /deimos/core/base.h | |
parent | 55bc67bf7989acfeadf0233a4bdd5660e8f0bb69 (diff) |
Swapchain creation
Diffstat (limited to 'deimos/core/base.h')
-rw-r--r-- | deimos/core/base.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/deimos/core/base.h b/deimos/core/base.h index 0c15ccd..4c74b33 100644 --- a/deimos/core/base.h +++ b/deimos/core/base.h @@ -64,8 +64,9 @@ struct SourceLocation {}
};
-template<typename T> T Min(T a, T b) { return (a < b) ? a : b; }
-template<typename T> T Max(T a, T b) { return (a > b) ? a : b; }
+template<typename T> constexpr T Min(T a, T b) { return (a < b) ? a : b; }
+template<typename T> constexpr T Max(T a, T b) { return (a > b) ? a : b; }
+template<typename T> constexpr T Clamp(T x, T min, T max) { return Min(Max(x, min), max); }
[[maybe_unused]] static constexpr int64_t Kilobytes = 1024;
[[maybe_unused]] static constexpr int64_t Megabytes = 1024 * 1024;
@@ -151,6 +152,15 @@ public: Expects(offset + size <= m_size);
return Span(m_begin + offset, size);
}
+
+ bool Contains(const T& v) const
+ {
+ for (const T& p: *this)
+ {
+ if (p == v) { return true; }
+ }
+ return false;
+ }
};
template<typename T>
|