config: added error messages to ENTT_ASSERT
This commit is contained in:
@@ -33,7 +33,7 @@ static_assert(ENTT_PAGE_SIZE && ((ENTT_PAGE_SIZE & (ENTT_PAGE_SIZE - 1)) == 0),
|
||||
# define ENTT_ASSERT(...) (void(0))
|
||||
#elif !defined ENTT_ASSERT
|
||||
# include <cassert>
|
||||
# define ENTT_ASSERT(condition) assert(condition)
|
||||
# define ENTT_ASSERT(condition, ...) assert(condition)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ template<std::size_t Len, std::size_t Align>
|
||||
template<typename Type, std::size_t Len, std::size_t Align>
|
||||
Type any_cast(const basic_any<Len, Align> &data) ENTT_NOEXCEPT {
|
||||
const auto * const instance = any_cast<std::remove_reference_t<Type>>(&data);
|
||||
ENTT_ASSERT(instance);
|
||||
ENTT_ASSERT(instance, "Invalid instance");
|
||||
return static_cast<Type>(*instance);
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
|
||||
Type any_cast(basic_any<Len, Align> &data) ENTT_NOEXCEPT {
|
||||
// forces const on non-reference types to make them work also with wrappers for const references
|
||||
auto * const instance = any_cast<std::remove_reference_t<const Type>>(&data);
|
||||
ENTT_ASSERT(instance);
|
||||
ENTT_ASSERT(instance, "Invalid instance");
|
||||
return static_cast<Type>(*instance);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
|
||||
Type any_cast(basic_any<Len, Align> &&data) ENTT_NOEXCEPT {
|
||||
// forces const on non-reference types to make them work also with wrappers for const references
|
||||
auto * const instance = any_cast<std::remove_reference_t<const Type>>(&data);
|
||||
ENTT_ASSERT(instance);
|
||||
ENTT_ASSERT(instance, "Invalid instance");
|
||||
return static_cast<Type>(std::move(*instance));
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "Group does not contain entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 0) {
|
||||
return std::tuple_cat(get_as_tuple(*std::get<storage_type<Get> *>(pools), entt)...);
|
||||
@@ -839,7 +839,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "Group does not contain entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 0) {
|
||||
return std::tuple_cat(get_as_tuple(*std::get<storage_type<Owned> *>(pools), entt)..., get_as_tuple(*std::get<storage_type<Get> *>(pools), entt)...);
|
||||
|
||||
@@ -129,12 +129,12 @@ class basic_registry {
|
||||
|
||||
Entity generate_identifier() {
|
||||
// traits_type::entity_mask is reserved to allow for null identifiers
|
||||
ENTT_ASSERT(static_cast<typename traits_type::entity_type>(entities.size()) < traits_type::entity_mask);
|
||||
ENTT_ASSERT(static_cast<typename traits_type::entity_type>(entities.size()) < traits_type::entity_mask, "No entities available");
|
||||
return entities.emplace_back(entity_type{static_cast<typename traits_type::entity_type>(entities.size())});
|
||||
}
|
||||
|
||||
Entity recycle_identifier() {
|
||||
ENTT_ASSERT(available != null);
|
||||
ENTT_ASSERT(available != null, "No entities available");
|
||||
const auto curr = to_integral(available);
|
||||
const auto version = to_integral(entities[curr]) & (traits_type::version_mask << traits_type::entity_shift);
|
||||
available = entity_type{to_integral(entities[curr]) & traits_type::entity_mask};
|
||||
@@ -201,13 +201,13 @@ public:
|
||||
* empty and thus invalid element otherwise.
|
||||
*/
|
||||
poly_storage & storage(const type_info info) {
|
||||
ENTT_ASSERT(info.seq() < pools.size() && pools[info.seq()].poly);
|
||||
ENTT_ASSERT(info.seq() < pools.size() && pools[info.seq()].poly, "Storage not available");
|
||||
return pools[info.seq()].poly;
|
||||
}
|
||||
|
||||
/*! @copydoc storage */
|
||||
const poly_storage & storage(const type_info info) const {
|
||||
ENTT_ASSERT(info.seq() < pools.size() && pools[info.seq()].poly);
|
||||
ENTT_ASSERT(info.seq() < pools.size() && pools[info.seq()].poly, "Storage not available");
|
||||
return pools[info.seq()].poly;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
*/
|
||||
[[nodiscard]] version_type current(const entity_type entity) const {
|
||||
const auto pos = size_type(to_integral(entity) & traits_type::entity_mask);
|
||||
ENTT_ASSERT(pos < entities.size());
|
||||
ENTT_ASSERT(pos < entities.size(), "Entity does not exist");
|
||||
return version(entities[pos]);
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ public:
|
||||
* @return A valid entity identifier.
|
||||
*/
|
||||
[[nodiscard]] entity_type create(const entity_type hint) {
|
||||
ENTT_ASSERT(hint != null);
|
||||
ENTT_ASSERT(hint != null, "Null entity not available");
|
||||
entity_type entt;
|
||||
|
||||
if(const auto req = (to_integral(hint) & traits_type::entity_mask); !(req < entities.size())) {
|
||||
@@ -467,7 +467,7 @@ public:
|
||||
*/
|
||||
template<typename It>
|
||||
void assign(It first, It last, const entity_type destroyed) {
|
||||
ENTT_ASSERT(!alive());
|
||||
ENTT_ASSERT(!alive(), "Entities still alive");
|
||||
entities.assign(first, last);
|
||||
available = destroyed;
|
||||
}
|
||||
@@ -537,7 +537,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
decltype(auto) emplace(const entity_type entity, Args &&... args) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
return assure<Component>()->emplace(*this, entity, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename It>
|
||||
void insert(It first, It last, const Component &value = {}) {
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }));
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }), "Invalid entity");
|
||||
assure<Component>()->insert(*this, first, last, value);
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ public:
|
||||
template<typename Component, typename EIt, typename CIt>
|
||||
void insert(EIt first, EIt last, CIt from, CIt to) {
|
||||
static_assert(std::is_constructible_v<Component, typename std::iterator_traits<CIt>::value_type>, "Invalid value type");
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }));
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }), "Invalid entity");
|
||||
assure<Component>()->insert(*this, first, last, from, to);
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
decltype(auto) emplace_or_replace(const entity_type entity, Args &&... args) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
auto *cpool = assure<Component>();
|
||||
|
||||
return cpool->contains(entity)
|
||||
@@ -634,7 +634,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename... Func>
|
||||
decltype(auto) patch(const entity_type entity, Func &&... func) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
return assure<Component>()->patch(*this, entity, std::forward<Func>(func)...);
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
void remove(const entity_type entity) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
static_assert(sizeof...(Component) > 0, "Provide one or more component types");
|
||||
(assure<Component>()->remove(entity, this), ...);
|
||||
}
|
||||
@@ -689,7 +689,7 @@ public:
|
||||
*/
|
||||
template<typename... Component, typename It>
|
||||
void remove(It first, It last) {
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }));
|
||||
ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); }), "Invalid entity");
|
||||
static_assert(sizeof...(Component) > 0, "Provide one or more component types");
|
||||
(assure<Component>()->remove(first, last, this), ...);
|
||||
}
|
||||
@@ -714,7 +714,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
size_type remove_if_exists(const entity_type entity) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
|
||||
return ([this, entity](auto *cpool) {
|
||||
return cpool->contains(entity) ? (cpool->remove(entity, this), true) : false;
|
||||
@@ -736,7 +736,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
void remove_all(const entity_type entity) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
entity_type wrap[1u]{entity};
|
||||
|
||||
for(auto pos = pools.size(); pos; --pos) {
|
||||
@@ -758,7 +758,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] bool all_of(const entity_type entity) const {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
return [entity](const auto *... cpool) { return ((cpool && cpool->contains(entity)) && ...); }(pool_if_exists<Component>()...);
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] bool any_of(const entity_type entity) const {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
return [entity](const auto *... cpool) { return !((!cpool || !cpool->contains(entity)) && ...); }(pool_if_exists<Component>()...);
|
||||
}
|
||||
|
||||
@@ -792,11 +792,11 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entity) const {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 1) {
|
||||
const auto *cpool = pool_if_exists<std::remove_const_t<Component>...>();
|
||||
ENTT_ASSERT(cpool);
|
||||
ENTT_ASSERT(cpool, "Storage not available");
|
||||
return cpool->get(entity);
|
||||
} else {
|
||||
return std::forward_as_tuple(get<Component>(entity)...);
|
||||
@@ -806,7 +806,7 @@ public:
|
||||
/*! @copydoc get */
|
||||
template<typename... Component>
|
||||
[[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entity) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 1) {
|
||||
return (const_cast<Component &>(assure<std::remove_const_t<Component>>()->get(entity)), ...);
|
||||
@@ -839,7 +839,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
[[nodiscard]] decltype(auto) get_or_emplace(const entity_type entity, Args &&... args) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
auto *cpool = assure<Component>();
|
||||
return cpool->contains(entity) ? cpool->get(entity) : cpool->emplace(*this, entity, std::forward<Args>(args)...);
|
||||
}
|
||||
@@ -859,7 +859,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
[[nodiscard]] auto try_get([[maybe_unused]] const entity_type entity) const {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 1) {
|
||||
const auto *cpool = pool_if_exists<std::remove_const_t<Component>...>();
|
||||
@@ -872,7 +872,7 @@ public:
|
||||
/*! @copydoc try_get */
|
||||
template<typename... Component>
|
||||
[[nodiscard]] auto try_get([[maybe_unused]] const entity_type entity) {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
|
||||
if constexpr(sizeof...(Component) == 1) {
|
||||
return (const_cast<Component *>(std::as_const(*this).template try_get<Component>(entity)), ...);
|
||||
@@ -940,7 +940,7 @@ public:
|
||||
* @return True if the entity has no components assigned, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool orphan(const entity_type entity) const {
|
||||
ENTT_ASSERT(valid(entity));
|
||||
ENTT_ASSERT(valid(entity), "Invalid entity");
|
||||
return std::none_of(pools.cbegin(), pools.cend(), [entity](auto &&pdata) { return pdata.pool && pdata.pool->contains(entity); });
|
||||
}
|
||||
|
||||
@@ -1203,7 +1203,7 @@ public:
|
||||
const auto overlapping = (0u + ... + gdata.owned(type_hash<std::remove_const_t<Owned>>::value()));
|
||||
const auto sz = overlapping + (0u + ... + gdata.get(type_hash<std::remove_const_t<Get>>::value())) + (0u + ... + gdata.exclude(type_hash<Exclude>::value()));
|
||||
return !overlapping || ((sz == size) || (sz == gdata.size));
|
||||
}));
|
||||
}), "Conflicting groups");
|
||||
|
||||
const auto next = std::find_if_not(groups.cbegin(), groups.cend(), [size](const auto &gdata) {
|
||||
return !(0u + ... + gdata.owned(type_hash<std::remove_const_t<Owned>>::value())) || (size > gdata.size);
|
||||
@@ -1370,7 +1370,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename Compare, typename Sort = std_sort, typename... Args>
|
||||
void sort(Compare compare, Sort algo = Sort{}, Args &&... args) {
|
||||
ENTT_ASSERT(sortable<Component>());
|
||||
ENTT_ASSERT(sortable<Component>(), "Cannot sort owned storage");
|
||||
assure<Component>()->sort(std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -1409,7 +1409,7 @@ public:
|
||||
*/
|
||||
template<typename To, typename From>
|
||||
void sort() {
|
||||
ENTT_ASSERT(sortable<To>());
|
||||
ENTT_ASSERT(sortable<To>(), "Cannot sort owned storage");
|
||||
assure<To>()->respect(*assure<From>());
|
||||
}
|
||||
|
||||
@@ -1548,7 +1548,7 @@ public:
|
||||
template<typename Type>
|
||||
[[nodiscard]] Type & ctx() const {
|
||||
auto it = std::find_if(vars.cbegin(), vars.cend(), [type = type_id<Type>()](auto &&var) { return var.type() == type; });
|
||||
ENTT_ASSERT(it != vars.cend());
|
||||
ENTT_ASSERT(it != vars.cend(), "Invalid instance");
|
||||
return any_cast<Type &>(*it);
|
||||
}
|
||||
|
||||
@@ -1556,7 +1556,7 @@ public:
|
||||
template<typename Type>
|
||||
[[nodiscard]] Type & ctx() {
|
||||
auto it = std::find_if(vars.begin(), vars.end(), [type = type_id<Type>()](auto &&var) { return var.type() == type; });
|
||||
ENTT_ASSERT(it != vars.end());
|
||||
ENTT_ASSERT(it != vars.end(), "Invalid instance");
|
||||
return any_cast<Type &>(*it);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ class basic_snapshot_loader {
|
||||
while(length--) {
|
||||
archive(entt);
|
||||
const auto entity = reg->valid(entt) ? entt : reg->create(entt);
|
||||
ENTT_ASSERT(entity == entt);
|
||||
ENTT_ASSERT(entity == entt, "Entity not available for use");
|
||||
reg->template emplace<Type>(entity);
|
||||
}
|
||||
} else {
|
||||
@@ -186,7 +186,7 @@ class basic_snapshot_loader {
|
||||
while(length--) {
|
||||
archive(entt, instance);
|
||||
const auto entity = reg->valid(entt) ? entt : reg->create(entt);
|
||||
ENTT_ASSERT(entity == entt);
|
||||
ENTT_ASSERT(entity == entt, "Entity not available for use");
|
||||
reg->template emplace<Type>(entity, std::move(instance));
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
: reg{&source}
|
||||
{
|
||||
// restoring a snapshot as a whole requires a clean registry
|
||||
ENTT_ASSERT(reg->empty());
|
||||
ENTT_ASSERT(reg->empty(), "Registry must be empty");
|
||||
}
|
||||
|
||||
/*! @brief Default move constructor. */
|
||||
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
* @return The position of the entity in the sparse set.
|
||||
*/
|
||||
[[nodiscard]] size_type index(const entity_type entt) const {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "Set does not contain entity");
|
||||
return size_type{to_integral(sparse[page(entt)][offset(entt)])};
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ public:
|
||||
* @return The entity at specified location.
|
||||
*/
|
||||
[[nodiscard]] entity_type operator[](const size_type pos) const {
|
||||
ENTT_ASSERT(pos < packed.size());
|
||||
ENTT_ASSERT(pos < packed.size(), "Position is out of bounds");
|
||||
return packed[pos];
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
* @param entt A valid entity identifier.
|
||||
*/
|
||||
void emplace(const entity_type entt) {
|
||||
ENTT_ASSERT(!contains(entt));
|
||||
ENTT_ASSERT(!contains(entt), "Set already contains entity");
|
||||
assure(page(entt))[offset(entt)] = entity_type{static_cast<typename traits_type::entity_type>(packed.size())};
|
||||
packed.push_back(entt);
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public:
|
||||
packed.insert(packed.end(), first, last);
|
||||
|
||||
for(; first != last; ++first) {
|
||||
ENTT_ASSERT(!contains(*first));
|
||||
ENTT_ASSERT(!contains(*first), "Set already contains entity");
|
||||
assure(page(*first))[offset(*first)] = entity_type{next++};
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
* @param ud Optional user data that are forwarded as-is to derived classes.
|
||||
*/
|
||||
void remove(const entity_type entt, void *ud = nullptr) {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "Set does not contain entity");
|
||||
auto &ref = sparse[page(entt)][offset(entt)];
|
||||
|
||||
// last chance to use the entity for derived classes and mixins, if any
|
||||
@@ -453,7 +453,7 @@ public:
|
||||
const auto other = packed.back();
|
||||
sparse[page(other)][offset(other)] = ref;
|
||||
// if it looks weird, imagine what the subtle bugs it prevents are
|
||||
ENTT_ASSERT((packed.back() = entt, true));
|
||||
ENTT_ASSERT((packed.back() = entt, true), "");
|
||||
packed[size_type{to_integral(ref)}] = other;
|
||||
ref = null;
|
||||
|
||||
@@ -527,11 +527,9 @@ public:
|
||||
*/
|
||||
template<typename Compare, typename Sort = std_sort, typename... Args>
|
||||
void sort_n(const size_type count, Compare compare, Sort algo = Sort{}, Args &&... args) {
|
||||
ENTT_ASSERT(!(count > size()));
|
||||
|
||||
algo(packed.rend() - count, packed.rend(), std::move(compare), std::forward<Args>(args)...);
|
||||
|
||||
for(size_type pos{}; pos < count; ++pos) {
|
||||
for(size_type pos{}, last = (size() < count ? size() : count); pos < last; ++pos) {
|
||||
auto curr = pos;
|
||||
auto next = index(packed[curr]);
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ public:
|
||||
* @param entt A valid entity identifier.
|
||||
*/
|
||||
void get([[maybe_unused]] const entity_type entt) const {
|
||||
ENTT_ASSERT(this->contains(entt));
|
||||
ENTT_ASSERT(this->contains(entt), "Storage does not contain entity");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,7 +550,7 @@ public:
|
||||
*/
|
||||
template<typename... Func>
|
||||
void patch([[maybe_unused]] const entity_type entity, Func &&... func) {
|
||||
ENTT_ASSERT(this->contains(entity));
|
||||
ENTT_ASSERT(this->contains(entity), "Storage does not contain entity");
|
||||
(std::forward<Func>(func)(), ...);
|
||||
}
|
||||
|
||||
@@ -638,7 +638,7 @@ class sigh_storage_mixin final: public Type {
|
||||
* @param ud Optional user data that are forwarded as-is to derived classes.
|
||||
*/
|
||||
void swap_and_pop(const std::size_t pos, void *ud) final {
|
||||
ENTT_ASSERT(ud != nullptr);
|
||||
ENTT_ASSERT(ud != nullptr, "Invalid pointer to registry");
|
||||
const auto entity = basic_sparse_set<typename Type::entity_type>::operator[](pos);
|
||||
destruction.publish(*static_cast<basic_registry<typename Type::entity_type> *>(ud), entity);
|
||||
// the position may have changed due to the actions of a listener
|
||||
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
[[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) const {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "View does not contain entity");
|
||||
|
||||
if constexpr(sizeof...(Comp) == 0) {
|
||||
return std::tuple_cat(get_as_tuple(*std::get<storage_type<Component> *>(pools), entt)...);
|
||||
@@ -860,7 +860,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
||||
ENTT_ASSERT(contains(entt));
|
||||
ENTT_ASSERT(contains(entt), "View does not contain entity");
|
||||
|
||||
if constexpr(sizeof...(Comp) == 0) {
|
||||
return get_as_tuple(*std::get<0>(pools), entt);
|
||||
|
||||
@@ -87,7 +87,7 @@ struct service_locator {
|
||||
* @param ptr Service to use to replace the current one.
|
||||
*/
|
||||
static void set(std::shared_ptr<Service> ptr) {
|
||||
ENTT_ASSERT(static_cast<bool>(ptr));
|
||||
ENTT_ASSERT(static_cast<bool>(ptr), "Null service not allowed");
|
||||
service = std::move(ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
};
|
||||
|
||||
entt::meta_any instance{std::forward<Key>(key)};
|
||||
ENTT_ASSERT(!internal::find_if_not(&instance, *curr, &node));
|
||||
ENTT_ASSERT(!internal::find_if_not(&instance, *curr, &node), "Duplicate key");
|
||||
property[0u] = std::move(instance);
|
||||
property[1u] = std::move(value);
|
||||
|
||||
@@ -191,7 +191,7 @@ struct meta_factory<Type> {
|
||||
auto type(const id_type id = type_hash<Type>::value()) {
|
||||
auto * const node = internal::meta_info<Type>::resolve();
|
||||
|
||||
ENTT_ASSERT(!internal::find_if_not(id, *internal::meta_context::global(), node));
|
||||
ENTT_ASSERT(!internal::find_if_not(id, *internal::meta_context::global(), node), "Duplicate identifier");
|
||||
node->id = id;
|
||||
|
||||
if(!internal::find_if(node, *internal::meta_context::global())) {
|
||||
@@ -434,7 +434,7 @@ struct meta_factory<Type> {
|
||||
&meta_getter<Type, Data, Policy>
|
||||
};
|
||||
|
||||
ENTT_ASSERT(!internal::find_if_not(id, type->data, &node));
|
||||
ENTT_ASSERT(!internal::find_if_not(id, type->data, &node), "Duplicate identifier");
|
||||
node.id = id;
|
||||
|
||||
if(!internal::find_if(&node, type->data)) {
|
||||
@@ -483,7 +483,7 @@ struct meta_factory<Type> {
|
||||
&meta_getter<Type, Getter, Policy>
|
||||
};
|
||||
|
||||
ENTT_ASSERT(!internal::find_if_not(id, type->data, &node));
|
||||
ENTT_ASSERT(!internal::find_if_not(id, type->data, &node), "Duplicate identifier");
|
||||
node.id = id;
|
||||
|
||||
if(!internal::find_if(&node, type->data)) {
|
||||
|
||||
@@ -426,9 +426,9 @@ public:
|
||||
*/
|
||||
template<typename Type>
|
||||
[[nodiscard]] Type cast() const {
|
||||
auto * const actual = try_cast<std::remove_reference_t<Type>>();
|
||||
ENTT_ASSERT(actual);
|
||||
return static_cast<Type>(*actual);
|
||||
auto * const instance = try_cast<std::remove_reference_t<Type>>();
|
||||
ENTT_ASSERT(instance, "Invalid instance");
|
||||
return static_cast<Type>(*instance);
|
||||
}
|
||||
|
||||
/*! @copydoc cast */
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
[[nodiscard]] Type cast() {
|
||||
// forces const on non-reference types to make them work also with wrappers for const references
|
||||
auto * const instance = try_cast<std::remove_reference_t<const Type>>();
|
||||
ENTT_ASSERT(instance);
|
||||
ENTT_ASSERT(instance, "Invalid instance");
|
||||
return static_cast<Type>(*instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,7 @@ class scheduler {
|
||||
struct continuation {
|
||||
continuation(process_handler *ref)
|
||||
: handler{ref}
|
||||
{
|
||||
ENTT_ASSERT(handler);
|
||||
}
|
||||
{}
|
||||
|
||||
template<typename Proc, typename... Args>
|
||||
continuation then(Args &&... args) {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct resource_handle {
|
||||
* @return A reference to the managed resource.
|
||||
*/
|
||||
[[nodiscard]] const Resource & get() const ENTT_NOEXCEPT {
|
||||
ENTT_ASSERT(static_cast<bool>(resource));
|
||||
ENTT_ASSERT(static_cast<bool>(resource), "Invalid resource");
|
||||
return *resource;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ struct resource_handle {
|
||||
* contains no resource at all.
|
||||
*/
|
||||
[[nodiscard]] const Resource * operator->() const ENTT_NOEXCEPT {
|
||||
ENTT_ASSERT(static_cast<bool>(resource));
|
||||
return resource.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
* @return The value returned by the underlying function.
|
||||
*/
|
||||
Ret operator()(Args... args) const {
|
||||
ENTT_ASSERT(static_cast<bool>(*this));
|
||||
ENTT_ASSERT(static_cast<bool>(*this), "Uninitialized delegate");
|
||||
return fn(data, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user