Timeline for Maintaining global states in a recursive function
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 22, 2023 at 6:44 | audit | Suggested edits | |||
Nov 22, 2023 at 8:00 | |||||
Nov 14, 2023 at 15:00 | vote | accept | CPlus | ||
Nov 14, 2023 at 11:57 | answer | added | gnasher729 | timeline score: 6 | |
Nov 14, 2023 at 0:25 | answer | added | candied_orange | timeline score: 8 | |
Nov 13, 2023 at 22:34 | review | Close votes | |||
Nov 18, 2023 at 3:08 | |||||
Nov 13, 2023 at 22:29 | comment | added | amon |
Just pass it as a param (possibly by pointer if the context data is larger than a pointer). If you have multiple context variables, bundle them as a struct. C++ closures are typically implemented exactly like that: an anonymous class, and performing a call involves an implicit this pointer argument. Don't bother with the register keyword, it is only advisory, is mostly ignored during optimization, and in any case only affects local variables and not a function call.
|
|
Nov 13, 2023 at 22:06 | history | asked | CPlus | CC BY-SA 4.0 |