60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Orange/Core/Types.h>
|
|
#include <Orange/Core/Traits.h>
|
|
|
|
namespace orange
|
|
{
|
|
template <typename T, size_t Size>
|
|
struct Array
|
|
{
|
|
constexpr Array()
|
|
: m_data{ } {}
|
|
|
|
constexpr Array(const T components[Size])
|
|
{
|
|
Copy(&components[0], &components[Size], begin());
|
|
}
|
|
|
|
constexpr Array(std::initializer_list<T> list)
|
|
{
|
|
Copy(list.begin(), list.end(), begin());
|
|
}
|
|
|
|
template <typename... Args>
|
|
constexpr Array(const Args&... args)
|
|
: m_data {{ args... }}
|
|
{
|
|
static_assert(sizeof...(Args) == Size);
|
|
}
|
|
|
|
constexpr Array(const Array& other) = default;
|
|
|
|
constexpr T& operator[](size_t index) { return m_data[index]; }
|
|
constexpr const T& operator[](size_t index) const { return m_data[index]; }
|
|
|
|
|
|
constexpr const T* begin() const { return &m_data[0]; }
|
|
constexpr T* begin() { return &m_data[0]; }
|
|
constexpr const T* end() const { return &m_data[Size]; }
|
|
constexpr T* end() { return &m_data[Size]; }
|
|
|
|
|
|
constexpr bool operator==(const Array& other) const
|
|
{
|
|
return Equal(begin(), end(), other.begin());
|
|
}
|
|
|
|
constexpr bool operator!=(const Array& other) const
|
|
{
|
|
return !operator==(other);
|
|
}
|
|
|
|
private:
|
|
|
|
T m_data[Size];
|
|
|
|
};
|
|
|
|
}
|