Selaa lähdekoodia

entity: mark functions [[nodiscard]] as needed

Michele Caini 1 vuosi sitten
vanhempi
commit
59935230dc

+ 1 - 1
src/entt/entity/handle.hpp

@@ -98,7 +98,7 @@ template<typename Registry, typename... Scope>
 class basic_handle {
     using traits_type = entt_traits<typename Registry::entity_type>;
 
-    auto &owner_or_assert() const noexcept {
+    [[nodiscard]] auto &owner_or_assert() const noexcept {
         ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
         return static_cast<Registry &>(*owner);
     }

+ 2 - 2
src/entt/entity/helper.hpp

@@ -22,7 +22,7 @@ namespace entt {
 template<typename Registry>
 class as_view {
     template<typename... Get, typename... Exclude>
-    auto dispatch(get_t<Get...>, exclude_t<Exclude...>) const {
+    [[nodiscard]] auto dispatch(get_t<Get...>, exclude_t<Exclude...>) const {
         return reg.template view<constness_as_t<typename Get::element_type, Get>...>(exclude_t<constness_as_t<typename Exclude::element_type, Exclude>...>{});
     }
 
@@ -61,7 +61,7 @@ private:
 template<typename Registry>
 class as_group {
     template<typename... Owned, typename... Get, typename... Exclude>
-    auto dispatch(owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>) const {
+    [[nodiscard]] auto dispatch(owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>) const {
         if constexpr(std::is_const_v<registry_type>) {
             return reg.template group_if_exists<typename Owned::element_type...>(get_t<typename Get::element_type...>{}, exclude_t<typename Exclude::element_type...>{});
         } else {

+ 1 - 1
src/entt/entity/mixin.hpp

@@ -37,7 +37,7 @@ class basic_sigh_mixin final: public Type {
 
     static_assert(std::is_base_of_v<basic_registry_type, owner_type>, "Invalid registry type");
 
-    auto &owner_or_assert() const noexcept {
+    [[nodiscard]] auto &owner_or_assert() const noexcept {
         ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
         return static_cast<owner_type &>(*owner);
     }

+ 1 - 1
src/entt/entity/sparse_set.hpp

@@ -1038,7 +1038,7 @@ public:
      * @brief Returned value type, if any.
      * @return Returned value type, if any.
      */
-    const type_info &type() const noexcept {
+    [[nodiscard]] const type_info &type() const noexcept {
         return *info;
     }
 

+ 2 - 2
src/entt/entity/view.hpp

@@ -216,7 +216,7 @@ class basic_common_view {
     template<typename Return, typename View, typename Other, std::size_t... VGet, std::size_t... VExclude, std::size_t... OGet, std::size_t... OExclude>
     friend Return internal::view_pack(const View &, const Other &, std::index_sequence<VGet...>, std::index_sequence<VExclude...>, std::index_sequence<OGet...>, std::index_sequence<OExclude...>);
 
-    auto offset() const noexcept {
+    [[nodiscard]] auto offset() const noexcept {
         ENTT_ASSERT(index != Get, "Invalid view");
         const auto *view = pools[index];
         const size_type len[]{view->size(), view->free_list()};
@@ -392,7 +392,7 @@ class basic_view<get_t<Get...>, exclude_t<Exclude...>>: public basic_common_view
     static constexpr bool tombstone_check_required = ((sizeof...(Get) == 1u) && ... && (Get::storage_policy == deletion_policy::in_place));
 
     template<std::size_t... Index>
-    auto get(const typename base_type::entity_type entt, std::index_sequence<Index...>) const noexcept {
+    [[nodiscard]] auto get(const typename base_type::entity_type entt, std::index_sequence<Index...>) const noexcept {
         return std::tuple_cat(storage<Index>()->get_as_tuple(entt)...);
     }