Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed, CXXGraph::Node::getData() should not be const #438 #462

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/CXXGraph/Node/Node_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Node {
const CXXGraph::id_t &getId() const;
const std::string &getUserId() const;
const T &getData() const;
T &getData() ;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra space before the semicolon. And the & should be next to T. Additionally, the function can be marked const (however the type returned should not be const T&).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. T& getData() const;

Copy link
Author

@yapa-ymtl yapa-ymtl Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not possible, We cannot overload a function based on return type.

void setData(T &&new_data);
// operator
bool operator==(const Node<T> &b) const;
Expand Down
7 changes: 6 additions & 1 deletion include/CXXGraph/Node/Node_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ const T &Node<T>::getData() const {
return data;
}

template <typename T>
T &Node<T>::getData() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - the & should be next to the T.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update

return data;
}

template <typename T>
void Node<T>::setData(T &&new_data) {
this->data = std::move(new_data);
Expand Down Expand Up @@ -92,4 +97,4 @@ std::ostream &operator<<(std::ostream &os, const Node<T> &node) {

} // namespace CXXGraph

#endif // __CXXGRAPH_NODE_IMPL_H__
#endif // __CXXGRAPH_NODE_IMPL_H__
Loading