From 35655e704063ddb4c0d6f7859106ff335c05e5c2 Mon Sep 17 00:00:00 2001 From: sbaldu Date: Mon, 9 Oct 2023 08:18:21 +0200 Subject: [PATCH] Specify different type trait for Node and Edge pointers, is_node_ptr and is_edge_ptr --- include/CXXGraph/Graph/Graph.hpp | 8 ++++---- include/CXXGraph/Utility/TypeTraits.hpp | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/CXXGraph/Graph/Graph.hpp b/include/CXXGraph/Graph/Graph.hpp index 22d9da0fa..64a2970b9 100644 --- a/include/CXXGraph/Graph/Graph.hpp +++ b/include/CXXGraph/Graph/Graph.hpp @@ -199,7 +199,7 @@ class Graph { * */ template - std::enable_if && (is_edge_v && ...), void> addEdges( + std::enable_if && (is_edge_ptr_v && ...), void> addEdges( T1 edge, Tn... edges); /** * \brief @@ -237,7 +237,7 @@ class Graph { * */ template - std::enable_if && (is_node_v && ...), void> addNodes( + std::enable_if && (is_node_ptr_v && ...), void> addNodes( T1 node, Tn... nodes); /** * \brief @@ -981,7 +981,7 @@ void Graph::addEdges() { template template -std::enable_if && (is_edge_v && ...), void> Graph::addEdges( +std::enable_if && (is_edge_ptr_v && ...), void> Graph::addEdges( T1 edge, Tn... edges) { addEdge(edge); addEdges(edges...); @@ -1006,7 +1006,7 @@ void Graph::addNodes() { template template -std::enable_if && (is_node_v && ...), void> Graph::addNodes( +std::enable_if && (is_node_ptr_v && ...), void> Graph::addNodes( T1 node, Tn... nodes) { addNode(node); addNodes(nodes...); diff --git a/include/CXXGraph/Utility/TypeTraits.hpp b/include/CXXGraph/Utility/TypeTraits.hpp index a8092443a..3c47c36b5 100755 --- a/include/CXXGraph/Utility/TypeTraits.hpp +++ b/include/CXXGraph/Utility/TypeTraits.hpp @@ -41,30 +41,38 @@ struct is_node : std::false_type {}; template struct is_node> : std::true_type {}; +// define is_node_ptr type trait for Node pointers and shared pointers template -struct is_node*> : std::true_type {}; +struct is_node_ptr : std::false_type {}; template -struct is_node>> : std::true_type {}; +struct is_node_ptr*> : std::true_type {}; template -inline constexpr bool is_node_v = is_node::value; +struct is_node_ptr>> : std::true_type {}; -// define is_edge type trait for Edges, Edges pointers and shared pointers +template +inline constexpr bool is_node_ptr_v = is_node::value; + +// define is_edge type trait for Edges template struct is_edge : std::false_type {}; template struct is_edge> : std::true_type {}; +// define is_edge_ptr type trait for Edge pointers and shared pointers +template +struct is_edge_ptr : std::false_type {}; + template -struct is_edge*> : std::true_type {}; +struct is_edge_ptr*> : std::true_type {}; template -struct is_edge>> : std::true_type {}; +struct is_edge_ptr>> : std::true_type {}; template -inline constexpr bool is_edge_v = is_edge::value; +inline constexpr bool is_edge_ptr_v = is_edge::value; } // namespace CXXGraph #endif