We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17fe8a9 commit 7a5ab33Copy full SHA for 7a5ab33
CppCoreGuidelines.md
@@ -13393,17 +13393,10 @@ Application concepts are easier to reason about.
13393
13394
##### Example
13395
13396
- void publish(std::string* msg)
13397
- {
13398
- // ...
13399
- *msg = "Hello";
13400
13401
- }
13402
-
13403
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
+ std::string msg, msg2;
+ std::thread publisher([&] { msg = "Hello"; }); // bad (less expressive and more error-prone)
+ auto pubtask = std::async([&] { msg2 = "Hello"; }); // OK
13407
// ...
13408
publisher.join();
13409
}
0 commit comments