use constexpr if

This commit is contained in:
Siarhei Fedartsou 2024-05-21 19:42:44 +02:00
parent 8654b16d8b
commit 09211b76e0
2 changed files with 50 additions and 42 deletions

View File

@ -265,14 +265,14 @@ jobs:
CXXCOMPILER: g++-12
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
# - name: gcc-11-release
# continue-on-error: false
# node: 20
# runs-on: ubuntu-22.04
# BUILD_TOOLS: ON
# BUILD_TYPE: Release
# CCOMPILER: gcc-11
# CXXCOMPILER: g++-11
- name: gcc-11-release
continue-on-error: false
node: 20
runs-on: ubuntu-22.04
BUILD_TOOLS: ON
BUILD_TYPE: Release
CCOMPILER: gcc-11
CXXCOMPILER: g++-11
- name: conan-linux-release-node
build_node_package: true

View File

@ -290,18 +290,23 @@ 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 = [&heapNode, &cell]() -> auto {
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>) {
auto distance = [&heapNode, &cell ]() -> auto
{
if constexpr (std::is_same_v<
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
return cell.GetOutDistance(heapNode.node).begin();
} else {
(void)cell;
(void)heapNode;
return 0;
}
}();
return cell.GetOutDistance(heapNode.node).begin();
}
else
{
(void)cell;
(void)heapNode;
return 0;
}
}
();
for (auto shortcut_weight : cell.GetOutWeight(heapNode.node))
{
BOOST_ASSERT(destination != cell.GetDestinationNodes().end());
@ -353,18 +358,23 @@ 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 = [&heapNode, &cell]() -> auto {
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>) {
auto distance = [&heapNode, &cell ]() -> auto
{
if constexpr (std::is_same_v<
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
return cell.GetOutDistance(heapNode.node).begin();
} else {
(void)cell;
(void)heapNode;
return 0;
}
}();
return cell.GetOutDistance(heapNode.node).begin();
}
else
{
(void)cell;
(void)heapNode;
return 0;
}
}
();
for (auto shortcut_weight : cell.GetInWeight(heapNode.node))
{
BOOST_ASSERT(source != cell.GetSourceNodes().end());
@ -437,14 +447,13 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
if (!toHeapNode)
{
if constexpr (std::is_same_v<
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const auto node_distance =
facade.GetNodeDistance(DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
const auto node_distance = facade.GetNodeDistance(
DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
const EdgeDistance to_distance = heapNode.data.distance + node_distance;
forward_heap.Insert(to, to_weight, {heapNode.node, false, to_distance});
}
@ -455,14 +464,13 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
}
else if (to_weight < toHeapNode->weight)
{
if constexpr (std::is_same_v<
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const auto node_distance =
facade.GetNodeDistance(DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
const auto node_distance = facade.GetNodeDistance(
DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
const EdgeDistance to_distance = heapNode.data.distance + node_distance;
toHeapNode->data = {heapNode.node, false, to_distance};
}