Struct as_view


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

template<typename Entity>
struct as_view


Converts a registry to a view.

Template Parameters

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


as_viewConstructs a converter for a given registry.
operator basic_view< entity_type, get_t< Component... >, Exclude >Conversion function from a registry to a view.


Lines 18-44 in src/entt/entity/helper.hpp.

template<typename Entity>
struct as_view {
    /*! @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_view(registry_type &source) ENTT_NOEXCEPT: reg{source} {}

     * @brief Conversion function from a registry to a view.
     * @tparam Exclude Types of components used to filter the view.
     * @tparam Component Type of components used to construct the view.
     * @return A newly created view.
    template<typename Exclude, typename... Component>
    operator basic_view<entity_type, get_t<Component...>, Exclude>() const {
        return reg.template view<Component...>(Exclude{});

    registry_type &reg;

Add Discussion

Log in to comment