From ee4ce45b36061964eec1602c7bd3692fb9a40a2f Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 4 Apr 2024 00:29:55 +0200 Subject: Start implementing Span --- deimos/core/base.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'deimos/core/base.h') 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 +class Span +{ + T* m_begin = nullptr; + int64_t m_size = 0; + +public: + constexpr Span() = default; + ~Span() = default; + + deimos_DEFAULT_COPY_MOVE(Span); + + template + requires std::convertible_to + constexpr Span(const Span& 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 -- cgit