// This file is a part of Framsticks SDK. http://www.framsticks.com/ // Copyright (C) 2019-2022 Maciej Komosinski and Szymon Ulatowski. // See LICENSE.txt for details. #ifndef _NONSTD_SPAN_H_ #define _NONSTD_SPAN_H_ // Remove this and use std::span when available (c++20) template class span { public: constexpr span() noexcept { data_ = NULL; size_ = 0; } constexpr span(ElementType* first, size_t count) noexcept { data_ = first; size_ = count; } constexpr span(ElementType* first, ElementType* end) noexcept { data_ = first; size_ = end - first; } template constexpr span(ElementType(&arr)[N]) noexcept { data_ = arr; size_ = N; } size_t size() const { return size_; } size_t size_bytes() const { return size_ * sizeof(ElementType); } ElementType& operator[](size_t idx) const { return data_[idx]; } ElementType* begin() const { return data_; } ElementType* end() const { return data_ + size_; } protected: ElementType* data_; size_t size_; }; #endif