Struct dynamic_sequence_container

Synopsis

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

template<typename Container>
struct dynamic_sequence_container

Description

STL-compatible dynamic sequence container traits.

Template Parameters

Container - The type of the container.

Methods

eraseRemoves the element at the specified location from the given container.
insertInserts an element at the specified location of the given container.
resizeResizes the given container to contain the given number of elements.

Source

Lines 188-223 in src/entt/meta/container.hpp.

template<typename Container>
struct dynamic_sequence_container {
    /**
     * @brief Resizes the given container to contain the given number of elements.
     * @param cont The container to resize.
     * @param sz The new size of the container.
     * @return True in case of success, false otherwise.
     */
    [[nodiscard]] static bool resize(Container &cont, typename Container::size_type sz) {
        return (cont.resize(sz), true);
    }

    /**
     * @brief Inserts an element at the specified location of the given container.
     * @param cont The container into which to insert the element.
     * @param it Iterator before which the element will be inserted.
     * @param value Element value to insert.
     * @return A pair consisting of an iterator to the inserted element (in case
     * of success) and a bool denoting whether the insertion took place.
     */
    [[nodiscard]] static std::pair<typename Container::iterator, bool> insert(Container &cont, typename Container::iterator it, const typename Container::value_type &value) {
        return { cont.insert(it, value), true };
    }

    /**
     * @brief Removes the element at the specified location from the given container.
     * @param cont The container from which to remove the element.
     * @param it Iterator to the element to remove.
     * @return A pair consisting of an iterator following the last removed
     * element (in case of success) and a bool denoting whether the insertion
     * took place.
     */
    [[nodiscard]] static std::pair<typename Container::iterator, bool> erase(Container &cont, typename Container::iterator it) {
        return { cont.erase(it), true };
    }
};





Add Discussion

Log in to comment