parameter problem in coroutine functions #1708
-
If I use coroutine, can the parameters of the function only be passed by value like the first function, and can they be passed by reference like the second function? |
Beta Was this translation helpful? Give feedback.
Answered by
VladlenPopolitov
Sep 9, 2023
Replies: 1 comment 3 replies
-
The parameters can't be passed by reference when using coroutines. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you take decision about reference parameter transfer, you have to consider the time of life for every parameter. You have to remember, that coroutines are not usual functions, they are created (coroutine handle and local memory allocated), called, returned execution to caller (looks like they sleep), resume again and again, and destroyed where they call co_return (handle and allocated variables memory destroyed and released).