X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/b21a698b1773f5b1d1fd78fb3817d4c195a0dab6..ac3670b33981698a02c5e95ab4f11cb3fe57562d:/include/stg/array.h diff --git a/include/stg/array.h b/include/stg/array.h new file mode 100644 index 00000000..8550f167 --- /dev/null +++ b/include/stg/array.h @@ -0,0 +1,44 @@ +#ifndef __STG_ARRAY_H__ +#define __STG_ARRAY_H__ + +#include // size_t + +namespace STG +{ + +template +class ARRAY +{ + public: + typedef T value_type; + typedef size_t size_type; + typedef T * iterator; + typedef const T * const_iterator; + + ARRAY() + { + for (size_type i = 0; i < S; ++i) + m_data[i] = value_type(); + } + + const value_type & operator[](size_type i) const { return m_data[i]; } + value_type & operator[](size_type i) { return m_data[i]; } + size_type size() const { return S; } + + iterator begin() { return &m_data[0]; } + const_iterator begin() const { return &m_data[0]; } + iterator end() { return &m_data[S + 1]; } + const_iterator end() const { return &m_data[S + 1]; } + + const value_type & front() const { return m_data[0]; } + value_type & front() { return m_data[0]; } + const value_type & back() const { return m_data[S]; } + value_type & back() { return m_data[S]; } + + private: + value_type m_data[S]; +}; + +} // namespace STG + +#endif