Created
March 25, 2019 08:52
-
-
Save y-fedorov/f025cf0ec43a31a4b84da83cfc72f474 to your computer and use it in GitHub Desktop.
BAD Example of code. C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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