isocpp / CppCoreGuidelines

The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Other
42.43k stars 5.42k forks source link

Should function parameter passing guidance cover async functions #1593

Open ChrisGuzak opened 4 years ago

ChrisGuzak commented 4 years ago

When passing values to functions that use co-routines those functions need to ensure they don't access values by reference in the continuation. This means parameter choice pushes you do taking things by value, for example a RECT class (4 numbers) is often best passed by const& but if it needs to be used after the suspension point by value is better.

Should this be discussed in F.16?

hsutter commented 4 years ago

Editors call: The Guidelines currently target C++17, and coroutines are in C++20 which is not yet published. The Guidelines document consensus experience and guidance, so once C++20 is used in the field we will look at adding guidance for coroutines.

cubbimew commented 3 years ago

Thanks to #1756 there is now a coroutine rule section, feel free to add!

hsutter commented 3 years ago

Editors call: Now that we're open for business for coroutines, we're reopening this... could you please submit a PR for a new guideline as you describe, with succinct rationale and bad/good examples, similar in format to the new CP.51 we just added, and make it CP.52? Thanks!