4 ms·
That will return 1. The defered code is executed after the return value is computed. This lets you do things like: char *str = foo(); defer { free(str); }
by gizmo686 2y ago
That will return 1. The defered code is executed after the return value is computed. This lets you do things like:
char *str = foo();
defer { free(str); }
return strlen(str);
- Jtsummers 2y agohttps://thephd.dev/_vendor/future_cxx/technical%20specification/C%20-%20defer/C%20-%20defer%20Technical%20Specification.pdf https://thephd.dev/_vendor/future_cxx/technical%20specificat... Right, there's a demonstration of GP's question (or a variation) on page 10 of the draft technical specification.