text: #ifndef STATIC_VECTOR_H
  #define STATIC_VECTOR_H
  
  #include <cstring>
  #include "ers/typedefs.h"
  
  namespace ers
  {
  	// ----------------------------
  	// ::::::::STATIC VECTOR:::::::
  	// ----------------------------	
  
  	// Simple std::vector-like class, with the same functionality as ers::Vector, 
  	// except it is allocated on the stack, not dynamically.
  
  	// Interface.
  	template <typename T, size_t CAPACITY>
  	class StaticVector
  	{
  	private:
  		size_t m_size;
  		T m_data[CAPACITY];
  
  	public:
  		StaticVector();
  
  		virtual ~StaticVector();
  
  		StaticVector(StaticVector&& v) noexcept;
  		StaticVector& operator =(StaticVector&& v) noexcept;
  
  		StaticVector(const StaticVector& v);
  		StaticVector& operator =(const StaticVector& v);
  
  		T& operator[] (size_t i);
  		const T& operator[] (size_t i) const;
  
  		// For ranged-for loops and iteration.
  		T* begin();
  		const T* begin() const;
  		T* end();
  		const T* end() const;
  
  		inline void Clear();
  
  		inline void PushFront(const T& value);
  		inline void PushFront(T&& value);
  
  		inline T PopFront();
  
  		inline void PushBack(const T& value);
  		inline void PushBack(T&& value);
  
  		inline T PopBack();
  
  		inline T* Find(const T& val);
  		inline size_t FindIndex(const T& val);
  
  		inline void EraseShift(T* it, size_t amount = 1);
  		inline void EraseShift(size_t idx, size_t amount = 1);
  
  		inline void EraseSwap(T* it, size_t amount = 1);
  		inline void EraseSwap(size_t idx, size_t amount = 1);
  
  		inline void Resize(size_t new_size);
  
  		inline size_t GetSize() const;
  		inline size_t GetCapacity() const;
  	};
  
  	/////////////////////////////////////////////////////////////////////////////////////////
  	// Implementation.
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>::StaticVector()
  		: m_size(0)
  	{
  		
  	}
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>::~StaticVector()
  	{
  		
  	}
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>::StaticVector(StaticVector&& v) noexcept
  	{
  		m_size = v.m_size;
  		for (size_t i = 0; i < m_size; ++i)
  			m_data[i] = std::move(v.m_data[i]);
  	}
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>& StaticVector<T, CAPACITY>::operator =(StaticVector&& v) noexcept
  	{
  		if (this != &v)
  		{
  			m_size = v.m_size;
  			for (size_t i = 0; i < m_size; ++i)
  				m_data[i] = std::move(v.m_data[i]);
  		}
  		return *this;
  	}
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>::StaticVector(const StaticVector& v)
  	{
  		m_size = v.m_size;
  		for (size_t i = 0; i < m_size; ++i)
  			m_data[i] = v.m_data[i];
  	}
  
  	template <typename T, size_t CAPACITY>
  	StaticVector<T, CAPACITY>& StaticVector<T, CAPACITY>::operator =(const StaticVector& v)
  	{
  		if (this != &v)
  		{
  			m_size = v.m_size;
  			for (size_t i = 0; i < m_size; ++i)
  				m_data[i] = v.m_data[i];
  		}
  		return *this;
  	}
  
  	template <typename T, size_t CAPACITY>
  	T& StaticVector<T, CAPACITY>::operator[](size_t i)
  	{
  		ERS_ASSERTF(i < m_size, "%s", "StaticVector::operator[]: Out of bounds.");
  		return m_data[i];
  	}
  
  	template <typename T, size_t CAPACITY>
  	const T& StaticVector<T, CAPACITY>::operator[](size_t i) const
  	{
  		ERS_ASSERTF(i < m_size, "%s", "StaticVector::operator[]: Out of bounds.");
  		return m_data[i];
  	}
  
  	template <typename T, size_t CAPACITY>
  	T* StaticVector<T, CAPACITY>::begin()
  	{
  		return &m_data[0];
  	}
  
  	template <typename T, size_t CAPACITY>
  	const T* StaticVector<T, CAPACITY>::begin() const
  	{
  		return &m_data[0];
  	}
  
  	template <typename T, size_t CAPACITY>
  	T* StaticVector<T, CAPACITY>::end()
  	{
  		return &m_data[0] + m_size;
  	}
  
  	template <typename T, size_t CAPACITY>
  	const T* StaticVector<T, CAPACITY>::end() const
  	{
  		return &m_data[0] + m_size;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::Clear()
  	{
  		m_size = 0;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::PushFront(const T& value)
  	{
  		size_t temp = m_size++;
  		ERS_ASSERTF(m_size <= CAPACITY, "%s", "StaticVector::PushFront: Exceeded capacity.");
  		for (size_t i = temp; i > 0; i--)
  			m_data[i] = std::move(m_data[i - 1]);
  		m_data[0] = T(value);
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::PushFront(T&& value)
  	{
  		size_t temp = m_size++;
  		ERS_ASSERTF(m_size <= CAPACITY, "%s", "StaticVector::PushFront: Exceeded capacity.");
  		for (size_t i = temp; i > 0; i--)
  			m_data[i] = std::move(m_data[i - 1]);
  		m_data[0] = value;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline T StaticVector<T, CAPACITY>::PopFront()
  	{
  		ERS_ASSERTF(m_size > 0, "%s", "StaticVector::PopFront: Empty vector.");
  		T out = T(std::move(m_data[0]));
  		EraseShift(size_t(0));
  		return out;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::PushBack(const T& value)
  	{
  		size_t temp = m_size++;
  		ERS_ASSERTF(m_size <= CAPACITY, "%s", "StaticVector::PushBack: Exceeded capacity.");
  		m_data[temp] = T(value);
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::PushBack(T&& value)
  	{
  		size_t temp = m_size++;
  		ERS_ASSERTF(m_size <= CAPACITY, "%s", "StaticVector::PushBack: Exceeded capacity.");
  		m_data[temp] = std::move(value);
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline T StaticVector<T, CAPACITY>::PopBack()
  	{
  		ERS_ASSERTF(m_size > 0, "%s", "StaticVector::PopBack: Empty StaticVector.");
  		--m_size;
  		T out = T(std::move(m_data[m_size]));
  		return out;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline T* StaticVector<T, CAPACITY>::Find(const T& val)
  	{
  		for (size_t i = 0; i < m_size; ++i)
  			if (m_data[i] == val)
  				return &m_data[i];
  		return nullptr;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline size_t StaticVector<T, CAPACITY>::FindIndex(const T& val)
  	{
  		for (size_t i = 0; i < m_size; ++i)
  			if (m_data[i] == val)
  				return i;
  		return CAPACITY;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::EraseShift(T* it, size_t amount)
  	{
  
  		ERS_ASSERTF(amount <= m_size && it - &m_data[0] <= m_size - amount, "%s", "StaticVector::EraseShift: Out of bounds.");
  		if (amount > 0)
  		{
  			T* finish = &m_data[0] + m_size;
  			T* from_end = finish - amount;
  			for (T* d = it; d != from_end; d++)
  				*d = std::move(*(d + amount));
  			m_size -= amount;
  		}
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::EraseShift(size_t idx, size_t amount)
  	{
  		ERS_ASSERTF(amount <= m_size && idx <= m_size - amount, "%s", "StaticVector::EraseShift: Out of bounds.");
  		if (amount > 0)
  		{
  			size_t from_end = m_size - amount;
  			for (size_t i = idx; i < from_end; i++)
  				m_data[i] = std::move(m_data[i + amount]);
  			m_size -= amount;
  		}
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::EraseSwap(T* it, size_t amount)
  	{
  		ERS_ASSERTF(amount <= m_size && it - &m_data[0] <= m_size - amount, "%s", "StaticVector::EraseSwap: Out of bounds.");
  		if (amount > 0)
  		{
  			T* from_end = &m_data[0] + m_size;
  			T* p = it;
  			T* stop = it + amount;
  			while (p != stop)
  				*p++ = std::move(*--from_end);
  			m_size -= amount;
  		}
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::EraseSwap(size_t idx, size_t amount)
  	{
  		ERS_ASSERTF(amount <= m_size && idx <= m_size - amount, "%s", "StaticVector::EraseSwap: Out of bounds.");
  		if (amount > 0)
  		{
  			T* from_end = &m_data[0] + m_size;
  			T* p = &m_data[0] + idx;
  			T* stop = p + amount;
  			while (p != stop)
  				*p++ = std::move(*--from_end);
  			m_size -= amount;
  		}
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline void StaticVector<T, CAPACITY>::Resize(size_t new_size)
  	{
  		ERS_ASSERTF(new_size <= CAPACITY, "%s", "StaticVector::Resize: New size exceeds capacity.");
  		m_size = new_size;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline size_t StaticVector<T, CAPACITY>::GetSize() const
  	{
  		return m_size;
  	}
  
  	template <typename T, size_t CAPACITY>
  	inline size_t StaticVector<T, CAPACITY>::GetCapacity() const
  	{
  		return CAPACITY;
  	}
  }
  #endif // STATIC_VECTOR_H