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

Make better use of C++11 features #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yeputons
Copy link

This PR is based on #3, which is scheduled to be merged after the course ends. I believe this PR's fate is going to be similar.

Things done:

  • Replace pure pointers with std::unique_ptr. If C++14 is allowed, some boilerplate can be replaced with std::make_unique. This also enables the full power of RAII and removes a lot of destructors.
  • Replace NULL with nullptr.
  • Mark overrides of virtual functions with override keyword instead of virtual (override implies virtual).

Things that can be improved:

  • Better use of move semantics. E.g. LSelectNode(BaseTable& table, std::vector<Predicate> predicates); always copies its second argument, even if it's a temporary value. If one replaces this->predicates = predicates; with this->predicates = std::move(predicates);, it will use move instead of copy in these situations.

@chernishev
Copy link
Owner

Thanks.

I dislike std::move, because its quite easy to get default copying behavior without any warning, if you do something wrong. Also, using std::move requires a bit of additional C++ understanding from a student, but this is course about databases (and it is already complex), not C++ programming.

Override and nullptr are good, other students already mentioned it. About uniques I will think, I recall that there were some considerations against having them in this project (aside from providing Valgrind playground).

@yeputons yeputons mentioned this pull request Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants