Struct unchecked_column

Synopsis

#include <include/flecs/addons/cpp/iter.hpp>

struct unchecked_column

Description

Unsafe wrapper class around a column. This class can be used when a system does not know the type of a column at compile time.

Methods

unchecked_column
operator[]Return element in component array

Source

Lines 9-33 in include/flecs/addons/cpp/iter.hpp.

struct unchecked_column {
    unchecked_column(void* array, size_t size, size_t count, bool is_shared = false)
        : m_array(array)
        , m_size(size)
        , m_count(count) 
        , m_is_shared(is_shared) {}

    /** Return element in component array.
     * This operator may only be used if the column is not shared.
     * 
     * @param index Index of element.
     * @return Reference to element.
     */
    void* operator[](size_t index) const {
        ecs_assert(index < m_count, ECS_COLUMN_INDEX_OUT_OF_RANGE, NULL);
        ecs_assert(!m_is_shared, ECS_INVALID_PARAMETER, NULL);
        return ECS_OFFSET(m_array, m_size * index);
    }

protected:
    void* m_array;
    size_t m_size;
    size_t m_count;
    bool m_is_shared;        
};