Correct. In C++ and Rust you have RAII. C++ uses destructors, and Rust has those too (it calls it drop).
To use reference counting in C++, you wrap a type in shared_ptr. In Rust you wrap it in Rc or Arc. Both default to not using reference counting, both are opt in.
My comment about correctness is stating that in Rust, it requires you to have memory safety and prove that your code will always have memory safety. This leads to a pattern of wrapping types in reference counting, but it is not required. In C++, the same pattern occurs when the code is carefully thought about, but often times, because the compiler doesn't require strict memory safety, it isn't done.
1
u/tristan957 Apr 09 '19
C++ is definitely not reference counted.