Struct as_group


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

template<typename Entity>
struct as_group


Converts a registry to a group.

Template Parameters

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


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


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

template<typename Entity>
struct as_group {
    /*! @brief Underlying entity identifier. */
    using entity_type = std::remove_const_t<Entity>;
    /*! @brief Type of registry to convert. */
    using registry_type = constness_as_t<basic_registry<entity_type>, 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 Get Types of components observed by the group.
     * @tparam Exclude Types of components used to filter the group.
     * @tparam Owned Types of components owned by the group.
     * @return A newly created group.
    template<typename Get, typename Exclude, typename... Owned>
    operator basic_group<entity_type, owned_t<Owned...>, Get, Exclude>() const {
        if constexpr(std::is_const_v<registry_type>) {
            return reg.template group_if_exists<Owned...>(Get{}, Exclude{});
        } else {
            return reg.template group<Owned...>(Get{}, Exclude{});

    registry_type &reg;

Add Discussion

Log in to comment