-
Notifications
You must be signed in to change notification settings - Fork 273
Enable goto_modelt move assignment #880
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
Enable goto_modelt move assignment #880
Conversation
This fails on windows because it doesn't understand On clang and gcc these should be |
fc0dc98
to
75a9525
Compare
src/goto-programs/goto_model.h
Outdated
goto_functions.swap(other.goto_functions); | ||
symbol_table = std::move(other.symbol_table); | ||
goto_functions = std::move(other.goto_functions); | ||
return *this; |
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.
My preference is to implement operator=
always in terms of swap
:
swap(other);
return *this;
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.
Surely that's less efficient as you're doing two moves instead of one?
75a9525
to
ac8a88e
Compare
src/goto-programs/goto_model.h
Outdated
goto_modelt &operator=(goto_modelt &&other) | ||
{ | ||
goto_modelt tmp(std::move(other)); | ||
swap(tmp); |
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.
This uses more stack than necessary. Can just
swap(other);
return *this;
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.
Sorry, wasn't thinking, of course you can if it's a move assignment.
6fd6cb9
to
1e2447d
Compare
goto_modelt
move assignment
goto_modelt
move assignment
src/goto-programs/goto_functions.h
Outdated
// under "Defaulted and Deleted Functions") | ||
|
||
goto_functionst(goto_functionst &&other) | ||
: goto_functions_templatet(std::move(other)) |
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.
put colon at end of previous line (several occurrences)
Propagate this change through goto_programt and goto_function_templatet
Rather than telling people not to use the copy constructor, actually don't use it
1e2447d
to
389fbcd
Compare
Previously
goto_modelt
implemented a non-standard move constructor and didn't enable the assignment operator. This replaces that code with the standard way of achieving the desired result.This also removes the copy constructor from
goto_functions_templatet
rather than just telling people not to use it.