Feature/to unique ptr
Intermediate replacement for std::unique_ptr
used in return types of some factory methods where currently raw pointers are returned.
Main features are: three conversion methods to raw-pointer, unique_ptr
and shared_ptr
.
Example of usage:
int* f_old() { return new int(1); } // old interface
to_unique_ptr<int> f_new() { return new int(2); } // new interface
// user code:
int* x1 = f_old();
int* x2 = f_new(); // works, because of implicit conversion to int*
std::unique_ptr<int> y1 { f_old() };
std::unique_ptr<int> y2 { f_new() };
std::unique_ptr<int> y3 = f_new();
The conversion to raw pointers is marked deprecated, so that the class to_unique_ptr
can be replaced by unique_ptr
in later releases.