Skip to content

Instantly share code, notes, and snippets.

@y-fedorov
Created March 25, 2019 08:52
Show Gist options
  • Save y-fedorov/f025cf0ec43a31a4b84da83cfc72f474 to your computer and use it in GitHub Desktop.
Save y-fedorov/f025cf0ec43a31a4b84da83cfc72f474 to your computer and use it in GitHub Desktop.
BAD Example of code. C++
/*
* Learning C++ Best Practices :: Avoid Defining Any Default Operations, Or Define Them All (Jason Turner)
* https://learning.oreilly.com/videos/learning-c-best/9781491954898/9781491954898-video241545
*/
#include <string>
struct S {
~S() {};
std::string s;
};
int main() {
std::vector<S> ss;
for (int i = 0; i < 100; ++i){
ss.emplace_back();
}
}
// problem: defined destructor prevents creating move constructor and move assignment operators for us. And it affects class usage performance!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment