mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Merge pull request #2137 from geoffliu/cleanup-cpp
Remove a section from c++, fixes #2130
This commit is contained in:
commit
cd16626c8f
@ -940,22 +940,6 @@ Foo f1;
|
||||
f1 = f2;
|
||||
|
||||
|
||||
// How to truly clear a container:
|
||||
class Foo { ... };
|
||||
vector<Foo> v;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
v.push_back(Foo());
|
||||
|
||||
// Following line sets size of v to 0, but destructors don't get called
|
||||
// and resources aren't released!
|
||||
v.clear();
|
||||
v.push_back(Foo()); // New value is copied into the first Foo we inserted
|
||||
|
||||
// Truly destroys all values in v. See section about temporary objects for
|
||||
// explanation of why this works.
|
||||
v.swap(vector<Foo>());
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// Tuples (C++11 and above)
|
||||
///////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user