6 ms·
C++23 is not too late to the party https://en.cppreference.com/w/cpp/memory/out_ptr_t/out_ptr https://en.cppreference.com/w/cpp/memory/out_ptr_t/out_ptr
by Congeec 4y ago
C++23 is not too late to the party https://en.cppreference.com/w/cpp/memory/out_ptr_t/out_ptr https://en.cppreference.com/w/cpp/memory/out_ptr_t/out_ptr
- int_19h 4y agoSo far as I can tell, it's not quite the same thing since these still have pointer semantics (and thus have to deal with aliasing etc). The in/out approach is more generic, since "in" can map to a pointer where it makes sense, and to a copy where it does not. Better yet when you prohibit such arguments from aliasing (or at least make no-alias the default) - now the compiler can also implement "in out" by copying the value back and forth, if it's faster than indirection.
- IAmLiterallyAB 4y agoEhh that's not quite what those are. The types being added for C++23 are designed for FFI. Herb made a proposal for proper in/out parameters for C++ in 2020 https://youtu.be/6lurOCdaj0Y https://youtu.be/6lurOCdaj0Y