-
Notifications
You must be signed in to change notification settings - Fork 449
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
Implement copy assignment operator for hvec_map #4388
Conversation
@grg Do you use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, although I am not familiar with hvec_map
.
@@ -52,7 +53,18 @@ class hvec_map : hash_vector_base { | |||
} | |||
hvec_map(const hvec_map &) = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test case showing the copy ctor works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, the name is misleading :) Certainly the copy assignment operator is implemented. And there is test for it (https://github.com/p4lang/p4c/pull/4388/files#diff-3c84a1bd26855410fe97ba63b1a655b54f10f618fbe2bb5471946ab7e33f9518R159)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I've noticed the implemented copy-assignment operator. At the same time, when we have implementation and test for copy assignment, we should also have a test for copy-construction -- if one is supposed to work, both should. Therefore, could you please add a test for the ctor, even though you have not touched it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done: 2e80292
No, I don't see any uses in either Tofino or IPU compiler code. |
since it would involved copying of std::pair<const KEY, VAL> that had its copy ctor explicitly disabled. Instead, go the standard "way" for maps via clear() and reinsert(). Fixes p4lang#4331
We cannot use a default one since it would involved copying of std::pair<const KEY, VAL> that had its copy ctor explicitly disabled.
Instead, go the "standard way" for maps via clear() and reinsert().
Fixes #4331