Class unsafe_column


#include <include/flecs/cpp/column.hpp>

class unsafe_column


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.


is_setReturn whether component is set
is_sharedReturn whether component is shared
operator[]Return element in component array


Lines 9-52 in include/flecs/cpp/column.hpp.

class unsafe_column {
    unsafe_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) {
        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);

    /** Return whether component is set.
     * If the column is optional, this method may return false.
     * @return True if component is set, false if component is not set.
    bool is_set() const {
        return m_array != nullptr;

    /** Return whether component is shared.
     * If the column is shared, this method returns true.
     * @return True if component is shared, false if component is owned.
    bool is_shared() const {
        return m_is_shared;

    void* m_array;
    size_t m_size;
    size_t m_count;
    bool m_is_shared;