Struct as_group

Synopsis

#include <src/entt/entity/helper.hpp>

template<bool Const, typename Entity>
struct as_group

Description

Converts a registry to a group.

Template Parameters:

Const - Constness of the accepted registry.

Entity - A valid entity type (see entt_traits for more details).

Methods

as_groupConstructs a converter for a given registry.
operator basic_group< Entity, Exclude, Get, Owned... >Conversion function from a registry to a group.

Source

Lines 70-95 in src/entt/entity/helper.hpp.

template<bool Const, typename Entity>
struct as_group {
    /*! @brief Type of registry to convert. */
    using registry_type = std::conditional_t<Const, const basic_registry<Entity>, basic_registry<Entity>>;

    /**
     * @brief Constructs a converter for a given registry.
     * @param source A valid reference to a registry.
     */
    as_group(registry_type &source) ENTT_NOEXCEPT: reg{source} {}

    /**
     * @brief Conversion function from a registry to a group.
     * @tparam Exclude Types of components used to filter the group.
     * @tparam Get Types of components observed by the group.
     * @tparam Owned Types of components owned by the group.
     * @return A newly created group.
     */
    template<typename Exclude, typename Get, typename... Owned>
    operator basic_group<Entity, Exclude, Get, Owned...>() const {
        return reg.template group<Owned...>(Get{}, Exclude{});
    }

private:
    registry_type &reg;
};





Add Discussion

Log in to comment