pioneerspacesim/pioneer — pull request #2519 by johnbartholomew (2013-10-30 21:28:30+00:00)
Title: Replace ScopedPtr/ScopedArray/ScopedMalloc with std::unique_ptr

Now that we've enabled C++11, we have access to `std::unique_ptr`. Our custom smart pointer types were fine (or at least as close to fine as I knew how to make them without C++11 features), but `std::unique_ptr` has some advantages:

* It is standard, so people should know how to use it, and if they don't there are plenty of resources for them to find out without having to be aware of any odd details that are specific to Pioneer.
* It is standard, so its implementation is written and maintained by people who know more about C++ than any of us, and who have thought carefully about every detail.
* It provides a safe mechanism for transferring ownership from one unique_ptr to another.

As before, you should be aware of whether you will be allocating with `new`, `new[]` or `malloc`/`calloc` and select the type appropriately:

* If you're allocating with `new`, use `std::unique_ptr`.
* If you're allocating with `new[]`, use `std::unique_ptr`.
* If you're allocating with `malloc` or `calloc`, use `std::unique_ptr` or (if you want to treat the data as an array) `std::unique_ptr`. (`FreeDeleter` is defined in `SmartPtr.h`.) Also, remember to cast the result of `malloc` to your chosen pointer type.