Skip to content

Commit

Permalink
Add move constructor for Node class
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed May 15, 2023
1 parent 3fe7ea5 commit 5f34333
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/Node/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class Node {
void setId(const std::string &);

public:
Node(const std::string &, T data);
Node(const std::string &, const T& data);
// Move constructor
Node(const std::string &, T&& data);
~Node() = default;
const std::size_t &getId() const;
const std::string &getUserId() const;
Expand All @@ -52,7 +54,15 @@ class Node {
};

template <typename T>
Node<T>::Node(const std::string& id, T data) {
Node<T>::Node(const std::string& id, const T& data) {
this->userId = id;
// the userid is set as sha512 hash of the user provided id
setId(id);
this->data = data;
}

template <typename T>
Node<T>::Node(const std::string& id, T&& data) {
this->userId = id;
// the userid is set as sha512 hash of the user provided id
setId(id);
Expand Down

0 comments on commit 5f34333

Please sign in to comment.