Skip to content

Commit 7a5ab33

Browse files
authored
Update CppCoreGuidelines.md
1 parent 17fe8a9 commit 7a5ab33

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

CppCoreGuidelines.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13393,17 +13393,10 @@ Application concepts are easier to reason about.
1339313393

1339413394
##### Example
1339513395

13396-
void publish(std::string* msg)
13397-
{
13398-
// ...
13399-
*msg = "Hello";
13400-
// ...
13401-
}
13402-
1340313396
void some_fun() {
13404-
std::string msg;
13405-
std::thread publisher(publish, &msg); // bad (less expressive and more error-prone)
13406-
auto pubtask = std::async(publish, &msg); // OK
13397+
std::string msg, msg2;
13398+
std::thread publisher([&] { msg = "Hello"; }); // bad (less expressive and more error-prone)
13399+
auto pubtask = std::async([&] { msg2 = "Hello"; }); // OK
1340713400
// ...
1340813401
publisher.join();
1340913402
}

0 commit comments

Comments
 (0)