BAN: Modify Span constructors to keep constness correctly

This commit is contained in:
Bananymous
2023-03-23 14:26:03 +02:00
parent e9da63ad79
commit 3ef72e8a7b
4 changed files with 26 additions and 8 deletions

View File

@@ -20,6 +20,10 @@ namespace BAN
public:
Span() = default;
Span(T*, size_type);
Span(Span<T>&);
template<typename S>
requires(is_same_v<T, const S>)
Span(const Span<S>&);
iterator begin() { return iterator(m_data); }
iterator end() { return iterator(m_data + m_size); }
@@ -51,6 +55,22 @@ namespace BAN
{
}
template<typename T>
Span<T>::Span(Span& other)
: m_data(other.data())
, m_size(other.size())
{
}
template<typename T>
template<typename S>
requires(is_same_v<T, const S>)
Span<T>::Span(const Span<S>& other)
: m_data(other.data())
, m_size(other.size())
{
}
template<typename T>
T& Span<T>::operator[](size_type index)
{