I wished to know if there is any construct provided by C++ so that we can have smart pointers behave as raw pointers with an additional capability of automatic destruction.
I understand that
1) We could use shared_ptr but it has issues of cyclic dependency.
2) unique_ptr, but then on assignment, the source pointer loses ownership.
Is there any construct that allows
3) automatic destruction like shared pointer and cyclic dependency is not there.
4) assignment works like raw pointer assignment and source ptr also has the ownership.
If there is any other best practice for replacing the raw pointer, kindly let me know. I'd be glad to know about the best practices for replacing raw pointers and avoiding memory leaks via any other language constructs or design.
(and don't even bother with shared_ptr unless you have a real non-deterministic non-hierarchical shared ownership problem - if you use shared_ptr appropriately, then "cyclic dependencies" never even come up)