Short version:
Is there an acceptable reason for using unthinkable pointers in modern C ++?
Short answer:
Certainly, if they serve only for observation, that is , they do not own pointee. However, try using links instead of pointers even in this case; use pointers only if you really need to make them optional (initialize with null_ptr and then reassign later, for example).
Long version:
we have a huge product that contains a lot of old C ++ code, and now we are trying to reorganize it to the modern era of C ++. [...]
Long answer:
As I read these lines, this answer comes to mind:
I would like this answer to be postponed more than once. I would say: “[...] for every refactor that we have made, we can justify“ this particular change will make the real task that we are doing now easier. ”Instead of“ now it is cleaner for future work. ”
In short, don't do a lot of refactoring unless you really need to.
So the question is: is there such a thing as using smart pointers?
In my opinion, std::shared_ptr overused. It is very convenient to use, and it gives you the illusion that you do not need to think about ownership problems. But this is not the whole picture. I totally agree with Sean Parent : "a generic pointer is as good as a global variable." Generic pointers can also introduce very complex ownership problems, etc.
On the other hand, if you need to allocate something on the heap, use unique_ptr . You cannot abuse it if you really need heap allocation. In my experience, using unique_ptr also leads to more understandable and understandable code, as ownership issues become clear.
Interesting talks from Sean Parent on how to avoid / reduce the use of pointers:
Hope this helps.