TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  OAL#004

Synopsis:In case allocated memory has to be deallocated later by someone else, use a unique_ptr with move semantics
Language:C++
Severity Level:1
Category:Object Allocation


Description:

Example:

std::unique_ptr<Foo> createFoo() { std::unique_ptr<Foo> ptr(new Foo); // return unique pointer to Foo return ptr; } void m() { auto foo = createFoo(); // transfer ownership of foo to bar Bar bar(std::move(foo)); }


Literature References:
Ellemtel Rec. 58