Luna/libluna/include/luna/Slice.h

53 lines
713 B
C
Raw Normal View History

2023-04-18 16:39:37 +00:00
#pragma once
#include <luna/Types.h>
template <typename T> class Slice
{
typedef T* Iterator;
typedef const T* ConstIterator;
public:
Slice(T* data, usize size) : m_data(data), m_size(size)
{
}
const T* data() const
{
return m_data;
}
T* data()
{
return m_data;
}
usize size() const
{
return m_size;
}
Iterator begin()
{
return m_data;
}
ConstIterator begin() const
{
return m_data;
}
Iterator end()
{
return m_data + m_size;
}
ConstIterator end() const
{
return m_data + m_size;
}
private:
T* const m_data;
const usize m_size;
};