Bug 2942

Summary: Add move support to Ptr
Product: ns-3 Reporter: Matthew Bradbury <matt-bradbury>
Component: coreAssignee: Peter Barnes <pdbarnes>
Status: NEW ---    
Severity: enhancement CC: ns-bugs
Priority: P3    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: Patch to add move support to Ptr

Description Matthew Bradbury 2018-07-06 11:11:13 EDT
Created attachment 3124 [details]
Patch to add move support to Ptr

Adding move support to Ptr in the form of the copy constructor and assignment operator can allow the compiler to avoid incrementing and decrementing the reference count. As SimpleRefCount is not implemented used atomics to manage the reference count (like std::shared_ptr) there are small performance wins by providing these methods.

Note that noexcept is added to certain functions as C++ containers will only use move operators if they guarantee no exceptions will be thrown. This means that any object managed by Ptr should never throw an exception in its destructor. This seems to be standard to the C++ std library [1].


[1] https://en.cppreference.com/w/cpp/memory/default_delete