Revamping your entire code due to new C++ functions

I just have a general question about how you programmers go about making use of new C++ functions when you've written a huge program pre C++11. Let's say you used pointers everywhere in the code, and then you learn that unique_ptr would have solved many of the issues that your code had with those pointers. What do you do? Do you try to replace many of the pointers with unique pointers, which would be very nightmarish, or do you start the code all over again using all the tools that you need (but weren't around when you wrote the code before)?
If it works, don't change it. Only changes may be retrofitting to take input/give output with new types.

Also, everyone was (should have been) using smart pointers before C++11 anyway, so that change is not complicated, especially since you only need to (should only need to) change a few typedefs here and there and maybe fix a few errors.
Last edited on
The tools you mention were around since about 1994 (which was the first time two kinds of smart pointers were proposed for standardization), they existed in many flavors and it took until c++11 to work out the final standard. I didn't use raw pointers to new'd objects in my code, except maybe when learning as a hobbyist.

But to answer the broader question, there is usually no business need to change C-with-classes, exception-unsafe, or otherwise poorly-written code if it solves the problem it was written to solve. It may take some project management effort to isolate it, so that new code can be written using modern practices, but rewriting existing code is rarely done. Remember, C++ was widely adopted in the industry in the first place because it allowed C code to be compiled in, almost as-is, side-by-side with C++ code.
Topic archived. No new replies allowed.