summaryrefslogtreecommitdiff
path: root/deimos/core/base.h
diff options
context:
space:
mode:
Diffstat (limited to 'deimos/core/base.h')
-rw-r--r--deimos/core/base.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/deimos/core/base.h b/deimos/core/base.h
index 2482e68..3dc3bad 100644
--- a/deimos/core/base.h
+++ b/deimos/core/base.h
@@ -53,5 +53,29 @@ struct SourceLocation
{}
};
+template<typename T>
+class Span
+{
+ T* m_begin = nullptr;
+ int64_t m_size = 0;
+
+public:
+ constexpr Span() = default;
+ ~Span() = default;
+
+ deimos_DEFAULT_COPY_MOVE(Span);
+
+ template<typename U>
+ requires std::convertible_to<U*, T*>
+ constexpr Span(const Span<U>& other) : // NOLINT
+ m_begin{other.begin()},
+ m_size{other.size()}
+ {}
+
+ constexpr T* begin() const { return m_begin; }
+ constexpr T* end() const { return m_begin + m_size; }
+ constexpr int64_t size() const { return m_size; }
+};
+
} // namespace deimos