summaryrefslogtreecommitdiff
path: root/deimos/core
diff options
context:
space:
mode:
Diffstat (limited to 'deimos/core')
-rw-r--r--deimos/core/allocator.h15
-rw-r--r--deimos/core/base.h14
2 files changed, 27 insertions, 2 deletions
diff --git a/deimos/core/allocator.h b/deimos/core/allocator.h
index 9e8dd87..f6adea2 100644
--- a/deimos/core/allocator.h
+++ b/deimos/core/allocator.h
@@ -143,6 +143,21 @@ public:
std::forward<A5>(arg5));
}
+ template<typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
+ constexpr gsl::owner<T*> New(
+ A0&& arg0, A1&& arg1, A2&& arg2, A3&& arg3, A4&& arg4, A5&& arg5, A6&& arg6,
+ const SourceLocation& source_location = {})
+ {
+ return NewInner<T>(source_location,
+ std::forward<A0>(arg0),
+ std::forward<A1>(arg1),
+ std::forward<A2>(arg2),
+ std::forward<A3>(arg3),
+ std::forward<A4>(arg4),
+ std::forward<A5>(arg5),
+ std::forward<A6>(arg6));
+ }
+
template<typename T>
void Delete(gsl::owner<T*> t, const SourceLocation& source_location = {})
{
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>