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 entt)

Description

Gets the element assigned to an entity from a storage, if any.

Template Parameters

Type - Storage type.

Parameters

container - A valid instance of a storage class.

entt - A valid entity identifier.

Returns
A possibly empty tuple containing the requested element.

Source

Lines 1030-1039 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 entt) {
    static_assert(std::is_same_v<std::remove_const_t<Type>, typename storage_traits<typename Type::entity_type, typename Type::value_type>::storage_type>, "Invalid storage");

    if constexpr(std::is_void_v<decltype(container.get({}))>) {
        return std::make_tuple();
    } else {
        return std::forward_as_tuple(container.get(entt));
    }
}





Add Discussion

Log in to comment