mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
Update CppCoreGuidelines.md
This commit is contained in:
@@ -13393,17 +13393,10 @@ Application concepts are easier to reason about.
|
|||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
void publish(std::string* msg)
|
|
||||||
{
|
|
||||||
// ...
|
|
||||||
*msg = "Hello";
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
void some_fun() {
|
void some_fun() {
|
||||||
std::string msg;
|
std::string msg, msg2;
|
||||||
std::thread publisher(publish, &msg); // bad (less expressive and more error-prone)
|
std::thread publisher([&] { msg = "Hello"; }); // bad (less expressive and more error-prone)
|
||||||
auto pubtask = std::async(publish, &msg); // OK
|
auto pubtask = std::async([&] { msg2 = "Hello"; }); // OK
|
||||||
// ...
|
// ...
|
||||||
publisher.join();
|
publisher.join();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user