From 6a39a88bf88f82146c457bdad54dfdf6d8c3ef88 Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Fri, 26 Aug 2016 03:47:38 +0200 Subject: [PATCH 1/2] Fix initializer list example --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 2f00f37..e1864b5 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -18865,11 +18865,11 @@ It is common to need an initial set of elements. template class Vector { public: - vector>; + Vector(std::initializer_list); // ... }; - Vector vs = { "Nygaard", "Ritchie" }; + Vector vs { "Nygaard", "Ritchie" }; ##### Enforcement From 2db47928df6e1054a17affa11138f3519f9f8f5c Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Fri, 26 Aug 2016 05:11:54 +0200 Subject: [PATCH 2/2] fix unnecessary block --- CppCoreGuidelines.md | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index e1864b5..085fc59 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -3436,25 +3436,21 @@ Pointers and references to locals shouldn't outlive their scope. Lambdas that ca ##### Example, bad - { - int local = 42; + int local = 42; - // Want a reference to local. - // Note, that after program exits this scope, - // local no longer exists, therefore - // process() call will have undefined behavior! - thread_pool.queue_work([&]{ process(local); }); - } + // Want a reference to local. + // Note, that after program exits this scope, + // local no longer exists, therefore + // process() call will have undefined behavior! + thread_pool.queue_work([&]{ process(local); }); ##### Example, good - { - int local = 42; - // Want a copy of local. - // Since a copy of local is made, it will be - // available at all times for the call. - thread_pool.queue_work([=]{ process(local); }); - } + int local = 42; + // Want a copy of local. + // Since a copy of local is made, it will be + // available at all times for the call. + thread_pool.queue_work([=]{ process(local); }); ##### Enforcement