From 6c29e226d8d6dd07392928ec2af01a5c26db63af Mon Sep 17 00:00:00 2001 From: Derek Li Date: Tue, 4 Oct 2016 12:55:52 +0100 Subject: [PATCH] P.11 call vector reserve(100) instead of vector(100) --- CppCoreGuidelines.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index f02b617..de51294 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -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 v(100); + vector v; + v.reserve(100); // ... for (int x; cin >> x; ) { // ... check that x is valid ...