Struct array< T, Size, enable_if_t< Size !=0 > >

Synopsis

#include <include/flecs/addons/cpp/utils/array.hpp>

template <typename T, size_t Size>
struct array<T, Size, enable_if_t<Size != 0> > final

Description

No description yet.

Methods

array overload
begin
each
end
operator[] overload
ptr
size

Source

Lines 38-82 in include/flecs/addons/cpp/utils/array.hpp.

template <typename T, size_t Size>
struct array<T, Size, enable_if_t<Size != 0> > final {
    array() {};

    array(const T (&elems)[Size]) {
        int i = 0;
        for (auto it = this->begin(); it != this->end(); ++ it) {
            *it = elems[i ++];
        }
    }

    T& operator[](int index) {
        return m_array[index];
    }

    T& operator[](size_t index) {
        return m_array[index];
    }

    array_iterator<T> begin() {
        return array_iterator<T>(m_array, 0);
    }

    array_iterator<T> end() {
        return array_iterator<T>(m_array, Size);
    }

    size_t size() {
        return Size;
    }

    T* ptr() {
        return m_array;
    }

    template <typename Func>
    void each(const Func& func) {
        for (auto& elem : *this) {
            func(elem);
        }
    }

private:
    T m_array[Size];
};