3 ms·
I don't think the parent meant free as in "free()" - more along the lines of. Foo f; DoSomething(std::move(f)); // can still use f here.
by maccard 11y ago
I don't think the parent meant free as in "free()" - more along the lines of.
Foo f;
DoSomething(std::move(f));
// can still use f here.
- deleted 11y ago[deleted]
- dragontamer 11y agoBut if "Foo" was composed of unique_ptr (or shared_ptr), then those smart pointers would be nulled out after the std::move (due to the default move constructor) So again, unless Foo f was composed of "raw pointers", even that kind of code is safe from "use after free" vulnerabilities.