Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Made distance functions constexpr #85

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/fiction/algorithms/path_finding/distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace fiction
* @return Manhattan distance between source and target.
*/
template <typename Lyt, typename Dist = uint64_t>
[[nodiscard]] Dist manhattan_distance([[maybe_unused]] const Lyt& lyt, const coordinate<Lyt>& source,
const coordinate<Lyt>& target) noexcept
[[nodiscard]] constexpr Dist manhattan_distance([[maybe_unused]] const Lyt& lyt, const coordinate<Lyt>& source,
const coordinate<Lyt>& target) noexcept
{
static_assert(is_coordinate_layout_v<Lyt>, "Lyt is not a coordinate layout");
static_assert(std::is_integral_v<Dist>, "Dist is not an integral type");
Expand All @@ -50,8 +50,8 @@ template <typename Lyt, typename Dist = uint64_t>
* @return Euclidean distance between source and target.
*/
template <typename Lyt, typename Dist = double>
[[nodiscard]] Dist euclidean_distance([[maybe_unused]] const Lyt& lyt, const coordinate<Lyt>& source,
const coordinate<Lyt>& target) noexcept
[[nodiscard]] constexpr Dist euclidean_distance([[maybe_unused]] const Lyt& lyt, const coordinate<Lyt>& source,
const coordinate<Lyt>& target) noexcept
{
static_assert(is_coordinate_layout_v<Lyt>, "Lyt is not a coordinate layout");
static_assert(std::is_floating_point_v<Dist>, "Dist is not a floating-point type");
Expand Down