CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

Should function parameter passing guidance cover async functions

Open ChrisGuzak opened this issue 5 years ago • 3 comments

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?

ChrisGuzak avatar Mar 31 '20 22:03 ChrisGuzak

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.

hsutter avatar Sep 03 '20 18:09 hsutter

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

cubbimew avatar Mar 11 '21 19:03 cubbimew

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!

hsutter avatar Mar 11 '21 19:03 hsutter