@@ -35,36 +35,30 @@ using std::make_shared;
3535using std::make_unique;
3636
3737template <typename T>
38- Edge<T>::Edge(const CXXGraph::id_t id, const Node<T> &node1,
39- const Node<T> &node2) {
40- this ->nodePair .first = make_shared<const Node<T>>(node1);
41- this ->nodePair .second = make_shared<const Node<T>>(node2);
42- this ->id = id;
43- }
38+ constexpr Edge<T>::Edge(const CXXGraph::id_t otherId, const Node<T> &node1,
39+ const Node<T> &node2)
40+ : id(otherId), nodePair{std::make_shared<const Node<T>>(node1),
41+ std::make_shared<const Node<T>>(node2)}
42+ {}
4443
4544template <typename T>
46- Edge<T>::Edge(const CXXGraph::id_t id, shared<const Node<T>> node1,
47- shared<const Node<T>> node2) {
48- this ->nodePair .first = node1;
49- this ->nodePair .second = node2;
50- this ->id = id;
51- }
45+ constexpr Edge<T>::Edge(const CXXGraph::id_t otherId, shared<const Node<T>> node1,
46+ shared<const Node<T>> node2)
47+ : id(otherId), nodePair(node1, node2) {}
5248
5349template <typename T>
54- Edge<T>::Edge(const CXXGraph::id_t id ,
55- const std::pair<const Node<T> *, const Node<T> *> &nodepair) {
56- this -> nodePair . first = make_shared< const Node<T>>(*(nodepair. first ));
57- this -> nodePair . second = make_shared<const Node<T>>(*(nodepair.second ));
58- this -> id = id;
59- }
50+ constexpr Edge<T>::Edge(const CXXGraph::id_t otherId ,
51+ const std::pair<const Node<T> *, const Node<T> *> &nodepair)
52+ : id(otherId)
53+ , nodePair(std:: make_shared<const Node<T>>(*(nodepair.first)),
54+ std::make_shared< const Node<T>>(*(nodepair.second)))
55+ { }
6056
6157template <typename T>
62- Edge<T>::Edge(
63- const CXXGraph::id_t id ,
58+ constexpr Edge<T>::Edge(
59+ const CXXGraph::id_t otherId ,
6460 const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair)
65- : nodePair(nodepair) {
66- this ->id = id;
67- }
61+ : id(otherId), nodePair(nodepair) { }
6862
6963template <typename T>
7064void Edge<T>::setFirstNode(shared<const Node<T>> node) {
@@ -79,7 +73,7 @@ void Edge<T>::setSecondNode(shared<const Node<T>> node) {
7973}
8074
8175template <typename T>
82- unsigned long long Edge<T>::getId() const {
76+ constexpr unsigned long long Edge<T>::getId() const {
8377 return id;
8478}
8579
@@ -114,7 +108,7 @@ bool Edge<T>::operator==(const Edge<T> &b) const {
114108}
115109
116110template <typename T>
117- bool Edge<T>::operator <(const Edge<T> &b) const {
111+ constexpr bool Edge<T>::operator <(const Edge<T> &b) const {
118112 return (this ->id < b.id );
119113}
120114
0 commit comments