Class meta_associative_container


#include <src/entt/meta/meta.hpp>

class meta_associative_container


Proxy object for associative containers.

Mentioned in


meta_associative_container overloadDefault constructor.
meta_associative_container overloadConstruct a proxy object for associative containers.
beginReturns an iterator to the first element of a container.
clearClears the content of a container.
endReturns an iterator that is past the last element of a container.
eraseRemoves the specified element from a container.
findReturns an iterator to the element with a given key, if any.
insertInserts an element (a key/value pair) into a container.
key_onlyReturns true if a container is also key-only, false otherwise.
key_typeReturns the meta key type of a container.
mapped_typeReturns the meta mapped type of a container.
operator boolReturns false if a proxy is invalid, true otherwise.
sizeReturns the size of a container.
value_typeReturns the meta value type of a container.


Lines 78-138 in src/entt/meta/meta.hpp.

class meta_associative_container {
    class meta_iterator;

    /*! @brief Unsigned integer type. */
    using size_type = std::size_t;
    /*! @brief Meta iterator type. */
    using iterator = meta_iterator;

    /*! @brief Default constructor. */
    meta_associative_container() ENTT_NOEXCEPT = default;

     * @brief Construct a proxy object for associative containers.
     * @tparam Type Type of container to wrap.
     * @param instance The container to wrap.
    template<typename Type>
    meta_associative_container(std::in_place_type_t<Type>, any instance) ENTT_NOEXCEPT
        : key_only_container{meta_associative_container_traits<Type>::key_only},
          key_type_node{internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::key_type>>>::resolve()},
          value_type_node{internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::value_type>>>::resolve()},
          storage{std::move(instance)} {
        if constexpr(!meta_associative_container_traits<Type>::key_only) {
            mapped_type_node = internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::mapped_type>>>::resolve();

    [[nodiscard]] inline bool key_only() const ENTT_NOEXCEPT;
    [[nodiscard]] inline meta_type key_type() const ENTT_NOEXCEPT;
    [[nodiscard]] inline meta_type mapped_type() const ENTT_NOEXCEPT;
    [[nodiscard]] inline meta_type value_type() const ENTT_NOEXCEPT;
    [[nodiscard]] inline size_type size() const ENTT_NOEXCEPT;
    inline bool clear();
    [[nodiscard]] inline iterator begin();
    [[nodiscard]] inline iterator end();
    inline bool insert(meta_any, meta_any);
    inline bool erase(meta_any);
    [[nodiscard]] inline iterator find(meta_any);
    [[nodiscard]] inline explicit operator bool() const ENTT_NOEXCEPT;

    bool key_only_container{};
    internal::meta_type_node *key_type_node = nullptr;
    internal::meta_type_node *mapped_type_node = nullptr;
    internal::meta_type_node *value_type_node = nullptr;
    size_type (*size_fn)(const any &) ENTT_NOEXCEPT = nullptr;
    bool (*clear_fn)(any &) = nullptr;
    iterator (*iter_fn)(any &, const bool) = nullptr;
    bool (*insert_fn)(any &, meta_any &, meta_any &) = nullptr;
    bool (*erase_fn)(any &, meta_any &) = nullptr;
    iterator (*find_fn)(any &, meta_any &) = nullptr;
    any storage{};

Add Discussion

Log in to comment