Bug 2942 - Add move support to Ptr
Add move support to Ptr
Status: NEW
Product: ns-3
Classification: Unclassified
Component: core
All All
: P3 enhancement
Assigned To: Peter Barnes
Depends on:
  Show dependency treegraph
Reported: 2018-07-06 11:11 EDT by Matthew Bradbury
Modified: 2018-07-06 11:11 EDT (History)
1 user (show)

See Also:

Patch to add move support to Ptr (2.21 KB, patch)
2018-07-06 11:11 EDT, Matthew Bradbury
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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