mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #760 from derekxgl/patch-1
P.11 call vector reserve(100) instead of vector(100)
This commit is contained in:
commit
6767413118
|
@ -998,7 +998,8 @@ This is low-level, verbose, and error-prone.
|
|||
For example, we "forgot" to test for memory exhaustion.
|
||||
Instead, we could use `vector`:
|
||||
|
||||
vector<int> v(100);
|
||||
vector<int> v;
|
||||
v.reserve(100);
|
||||
// ...
|
||||
for (int x; cin >> x; ) {
|
||||
// ... check that x is valid ...
|
||||
|
|
Loading…
Reference in New Issue
Block a user