From 5489c296e9342717d2134c445f045a6a0dc23b3e Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 5 May 2025 02:24:23 +0300 Subject: [PATCH] added more noexcept --- include/omath/pathfinding/a_star.hpp | 6 +++--- include/omath/pathfinding/navigation_mesh.hpp | 8 ++++---- source/pathfinding/a_star.cpp | 6 +++--- source/pathfinding/navigation_mesh.cpp | 9 +++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/omath/pathfinding/a_star.hpp b/include/omath/pathfinding/a_star.hpp index ba5041d..d894e76 100644 --- a/include/omath/pathfinding/a_star.hpp +++ b/include/omath/pathfinding/a_star.hpp @@ -15,16 +15,16 @@ namespace omath::pathfinding public: [[nodiscard]] static std::vector> find_path(const Vector3& start, const Vector3& end, - const NavigationMesh& nav_mesh); + const NavigationMesh& nav_mesh) noexcept; private: [[nodiscard]] static std::vector> reconstruct_final_path(const std::unordered_map, PathNode>& closed_list, - const Vector3& current); + const Vector3& current) noexcept; [[nodiscard]] static auto get_perfect_node(const std::unordered_map, PathNode>& open_list, - const Vector3& end_vertex); + const Vector3& end_vertex) noexcept; }; } // namespace omath::pathfinding diff --git a/include/omath/pathfinding/navigation_mesh.hpp b/include/omath/pathfinding/navigation_mesh.hpp index 588681b..75ba634 100644 --- a/include/omath/pathfinding/navigation_mesh.hpp +++ b/include/omath/pathfinding/navigation_mesh.hpp @@ -20,17 +20,17 @@ namespace omath::pathfinding { public: [[nodiscard]] - std::expected, std::string> get_closest_vertex(const Vector3& point) const; + std::expected, std::string> get_closest_vertex(const Vector3& point) const noexcept; [[nodiscard]] - const std::vector>& get_neighbors(const Vector3& vertex) const; + const std::vector>& get_neighbors(const Vector3& vertex) const noexcept; [[nodiscard]] bool empty() const; - [[nodiscard]] std::vector serialize() const; + [[nodiscard]] std::vector serialize() const noexcept; - void deserialize(const std::vector& raw); + void deserialize(const std::vector& raw) noexcept; std::unordered_map, std::vector>> m_vertex_map; }; diff --git a/source/pathfinding/a_star.cpp b/source/pathfinding/a_star.cpp index 593c907..bcd7348 100644 --- a/source/pathfinding/a_star.cpp +++ b/source/pathfinding/a_star.cpp @@ -17,7 +17,7 @@ namespace omath::pathfinding std::vector> Astar::reconstruct_final_path(const std::unordered_map, PathNode>& closed_list, - const Vector3& current) + const Vector3& current) noexcept { std::vector> path; std::optional current_opt = current; @@ -38,7 +38,7 @@ namespace omath::pathfinding return path; } auto Astar::get_perfect_node(const std::unordered_map, PathNode>& open_list, - const Vector3& end_vertex) + const Vector3& end_vertex) noexcept { return std::ranges::min_element(open_list, [&end_vertex](const auto& a, const auto& b) @@ -50,7 +50,7 @@ namespace omath::pathfinding } std::vector> Astar::find_path(const Vector3& start, const Vector3& end, - const NavigationMesh& nav_mesh) + const NavigationMesh& nav_mesh) noexcept { std::unordered_map, PathNode> closed_list; std::unordered_map, PathNode> open_list; diff --git a/source/pathfinding/navigation_mesh.cpp b/source/pathfinding/navigation_mesh.cpp index 97c7dc1..b2a831b 100644 --- a/source/pathfinding/navigation_mesh.cpp +++ b/source/pathfinding/navigation_mesh.cpp @@ -6,7 +6,8 @@ #include namespace omath::pathfinding { - std::expected, std::string> NavigationMesh::get_closest_vertex(const Vector3& point) const + std::expected, std::string> + NavigationMesh::get_closest_vertex(const Vector3& point) const noexcept { const auto res = std::ranges::min_element(m_vertex_map, [&point](const auto& a, const auto& b) { return a.first.distance_to(point) < b.first.distance_to(point); }); @@ -17,7 +18,7 @@ namespace omath::pathfinding return res->first; } - const std::vector>& NavigationMesh::get_neighbors(const Vector3& vertex) const + const std::vector>& NavigationMesh::get_neighbors(const Vector3& vertex) const noexcept { return m_vertex_map.at(vertex); } @@ -27,7 +28,7 @@ namespace omath::pathfinding return m_vertex_map.empty(); } - std::vector NavigationMesh::serialize() const + std::vector NavigationMesh::serialize() const noexcept { auto dump_to_vector = [](const T& t, std::vector& vec) { @@ -50,7 +51,7 @@ namespace omath::pathfinding return raw; } - void NavigationMesh::deserialize(const std::vector& raw) + void NavigationMesh::deserialize(const std::vector& raw) noexcept { auto load_from_vector = [](const std::vector& vec, size_t& offset, auto& value) {