General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
812 B

#pragma once
#include <gp/buffer.hpp>
namespace gp{
template<typename T, std::size_t sz>
class array{
T ary[sz];
public:
using associated_iterator = typename buffer<T>::associated_iterator;
constexpr T& operator[] (size_t off)
{
return ary[off];
}
constexpr size_t size() const
{
return sz;
}
constexpr associated_iterator begin() const
{
return gp::buffer<T>{(T*)ary, (T*)ary+sz}.begin();
}
constexpr associated_iterator end() const
{
return gp::buffer<T>{(T*)ary, (T*)ary+sz}.end();
}
constexpr bool operator==(const array& oth) const
{
for(size_t idx = 0; idx<sz; idx++)
{
if(ary[idx] != oth.ary[idx])
{
return false;
}
}
return true;
}
gp::buffer<T> as_buffer()
{
return gp::buffer<T>{(T*)ary, (T*)ary+sz};
}
};
}