Skip to content

Commit 35655e7

Browse files
committed
Specify different type trait for Node and Edge pointers, is_node_ptr and is_edge_ptr
1 parent c2d7ef5 commit 35655e7

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

include/CXXGraph/Graph/Graph.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Graph {
199199
*
200200
*/
201201
template <typename T1, typename... Tn>
202-
std::enable_if<is_edge_v<T1> && (is_edge_v<Tn> && ...), void> addEdges(
202+
std::enable_if<is_edge_ptr_v<T1> && (is_edge_ptr_v<Tn> && ...), void> addEdges(
203203
T1 edge, Tn... edges);
204204
/**
205205
* \brief
@@ -237,7 +237,7 @@ class Graph {
237237
*
238238
*/
239239
template <typename T1, typename... Tn>
240-
std::enable_if<is_node_v<T1> && (is_node_v<Tn> && ...), void> addNodes(
240+
std::enable_if<is_node_ptr_v<T1> && (is_node_ptr_v<Tn> && ...), void> addNodes(
241241
T1 node, Tn... nodes);
242242
/**
243243
* \brief
@@ -981,7 +981,7 @@ void Graph<T>::addEdges() {
981981

982982
template <typename T>
983983
template <typename T1, typename... Tn>
984-
std::enable_if<is_edge_v<T1> && (is_edge_v<Tn> && ...), void> Graph<T>::addEdges(
984+
std::enable_if<is_edge_ptr_v<T1> && (is_edge_ptr_v<Tn> && ...), void> Graph<T>::addEdges(
985985
T1 edge, Tn... edges) {
986986
addEdge(edge);
987987
addEdges(edges...);
@@ -1006,7 +1006,7 @@ void Graph<T>::addNodes() {
10061006

10071007
template <typename T>
10081008
template <typename T1, typename... Tn>
1009-
std::enable_if<is_node_v<T1> && (is_node_v<Tn> && ...), void> Graph<T>::addNodes(
1009+
std::enable_if<is_node_ptr_v<T1> && (is_node_ptr_v<Tn> && ...), void> Graph<T>::addNodes(
10101010
T1 node, Tn... nodes) {
10111011
addNode(node);
10121012
addNodes(nodes...);

include/CXXGraph/Utility/TypeTraits.hpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,38 @@ struct is_node : std::false_type {};
4141
template <typename T>
4242
struct is_node<Node<T>> : std::true_type {};
4343

44+
// define is_node_ptr type trait for Node pointers and shared pointers
4445
template <typename T>
45-
struct is_node<const Node<T>*> : std::true_type {};
46+
struct is_node_ptr : std::false_type {};
4647

4748
template <typename T>
48-
struct is_node<shared<const Node<T>>> : std::true_type {};
49+
struct is_node_ptr<const Node<T>*> : std::true_type {};
4950

5051
template <typename T>
51-
inline constexpr bool is_node_v = is_node<T>::value;
52+
struct is_node_ptr<shared<const Node<T>>> : std::true_type {};
5253

53-
// define is_edge type trait for Edges, Edges pointers and shared pointers
54+
template <typename T>
55+
inline constexpr bool is_node_ptr_v = is_node<T>::value;
56+
57+
// define is_edge type trait for Edges
5458
template <typename T>
5559
struct is_edge : std::false_type {};
5660

5761
template <typename T>
5862
struct is_edge<Edge<T>> : std::true_type {};
5963

64+
// define is_edge_ptr type trait for Edge pointers and shared pointers
65+
template <typename T>
66+
struct is_edge_ptr : std::false_type {};
67+
6068
template <typename T>
61-
struct is_edge<const Edge<T>*> : std::true_type {};
69+
struct is_edge_ptr<const Edge<T>*> : std::true_type {};
6270

6371
template <typename T>
64-
struct is_edge<shared<const Edge<T>>> : std::true_type {};
72+
struct is_edge_ptr<shared<const Edge<T>>> : std::true_type {};
6573

6674
template <typename T>
67-
inline constexpr bool is_edge_v = is_edge<T>::value;
75+
inline constexpr bool is_edge_ptr_v = is_edge<T>::value;
6876
} // namespace CXXGraph
6977

7078
#endif

0 commit comments

Comments
 (0)