Skip to content

Commit

Permalink
use constexpr if
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed May 22, 2024
1 parent 298a8e4 commit 5e0f226
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/engine/routing_algorithms/routing_base_mld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <boost/assert.hpp>

#include <algorithm>
#include <boost/core/ignore_unused.hpp>
#include <iterator>
#include <limits>
#include <tuple>
Expand Down Expand Up @@ -311,15 +312,16 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto &cell =
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
auto destination = cell.GetDestinationNodes().begin();
auto distance = [&]() -> auto
auto distance = [&cell, node = heapNode.node ]() -> auto
{
if constexpr (IS_MAP_MATCHING)
{

return cell.GetOutDistance(heapNode.node).begin();
return cell.GetOutDistance(node).begin();
}
else
{
boost::ignore_unused(cell, node);
return 0;
}
}
Expand All @@ -346,7 +348,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
}
}
++destination;
if (IS_MAP_MATCHING)
if constexpr (IS_MAP_MATCHING)
{
++distance;
}
Expand All @@ -358,15 +360,16 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto &cell =
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
auto source = cell.GetSourceNodes().begin();
auto distance = [&]() -> auto
auto distance = [&cell, node = heapNode.node ]() -> auto
{
if constexpr (IS_MAP_MATCHING)
{

return cell.GetInDistance(heapNode.node).begin();
return cell.GetInDistance(node).begin();
}
else
{
boost::ignore_unused(cell, node);
return 0;
}
}
Expand All @@ -392,7 +395,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
}
}
++source;
if (IS_MAP_MATCHING)
if constexpr (IS_MAP_MATCHING)
{
++distance;
}
Expand Down

0 comments on commit 5e0f226

Please sign in to comment.