Function get_as_tuple

Synopsis

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

template <typename Type>
auto get_as_tuple([[maybe_unused]] Type &container, [[maybe_unused]] const typename Type::entity_type entity)

Description

Gets the element associated with an entity from a storage, if any.

Template Parameters

Type - Storage type.

Parameters

container - A valid instance of a storage class.

entity - A valid entity identifier.

Returns
A possibly empty tuple containing the requested element.

Source

Lines 816-826 in src/entt/entity/storage.hpp.

template<typename Type>
[[nodiscard]] auto get_as_tuple([[maybe_unused]] Type &container, [[maybe_unused]] const typename Type::entity_type entity) {
    static_assert(std::is_same_v<std::remove_const_t<Type>, typename storage_traits<typename Type::entity_type, typename Type::value_type>::storage_type>);

    if constexpr(std::is_base_of_v<dense_storage_tag, typename Type::storage_category>) {
        return std::forward_as_tuple(container.get(entity));
    } else {
        static_assert(std::is_base_of_v<empty_storage_tag, typename Type::storage_category>, "Unknown storage category");
        return std::make_tuple();
    }
}





Add Discussion

Log in to comment