libluna: Allow constructing a Slice from another one with a different pointer type
This commit is contained in:
parent
cb28e2a385
commit
36bc217056
@ -11,6 +11,10 @@ template <typename T> class Slice
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Tp> Slice(const Slice<Tp>& other) : m_data((T*)other.m_data), m_size(other.m_size)
|
||||
{
|
||||
}
|
||||
|
||||
const T* data() const
|
||||
{
|
||||
return m_data;
|
||||
@ -46,6 +50,18 @@ template <typename T> class Slice
|
||||
return m_data + m_size;
|
||||
}
|
||||
|
||||
const T& operator[](usize index) const
|
||||
{
|
||||
check(index < m_size);
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
T& operator[](usize index)
|
||||
{
|
||||
check(index < m_size);
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
private:
|
||||
T* const m_data;
|
||||
const usize m_size;
|
||||
|
Loading…
Reference in New Issue
Block a user