Update CppCoreGuidelines.md

This commit is contained in:
Jonathan Wakely 2017-10-23 19:24:53 +01:00 committed by GitHub
parent 17fe8a957f
commit 7a5ab334a0

View File

@ -13393,17 +13393,10 @@ Application concepts are easier to reason about.
##### Example
void publish(std::string* msg)
{
// ...
*msg = "Hello";
// ...
}
void some_fun() {
std::string msg;
std::thread publisher(publish, &msg); // bad (less expressive and more error-prone)
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
// ...
publisher.join();
}