From 754fddf1abc4d6ed7b50766f667d6db7ca7cc754 Mon Sep 17 00:00:00 2001 From: sbaldu Date: Tue, 3 Oct 2023 10:02:20 +0200 Subject: [PATCH] Add dynamic_cast in raw pointer overload of addEdge --- include/CXXGraph/Graph/Graph.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/CXXGraph/Graph/Graph.hpp b/include/CXXGraph/Graph/Graph.hpp index 166766bc3..9c108bd2d 100644 --- a/include/CXXGraph/Graph/Graph.hpp +++ b/include/CXXGraph/Graph/Graph.hpp @@ -861,7 +861,8 @@ template void Graph::addEdge(const Edge *edge) { if (edge->isDirected().has_value() && edge->isDirected().value()) { if (edge->isWeighted().has_value() && edge->isWeighted().value()) { - auto edge_shared = make_shared>(*edge); + auto edge_shared = make_shared>( + *dynamic_cast *>(edge)); this->edgeSet.insert(edge_shared); std::pair>, shared>> elem = { @@ -879,7 +880,8 @@ void Graph::addEdge(const Edge *edge) { } } else { if (edge->isWeighted().has_value() && edge->isWeighted().value()) { - auto edge_shared = make_shared>(*edge); + auto edge_shared = make_shared>( + *dynamic_cast *>(edge)); this->edgeSet.insert(edge_shared); std::pair>, shared>> elem = {