Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2015, 10:06:23 PM (8 years ago)
Author:
landauf
Message:

added move-constructor for StrongPtr and SharedPtr. for WeakPtr this is not useful because the weakPtr is registered in Destroyable, so a copy-constructor must be used anyway

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/util/SharedPtr.h

    r10624 r10745  
    245245            }
    246246
     247            /// Move-constructor, this SharedPtr now points to the same object like the other SharedPtr did before
     248            inline SharedPtr(SharedPtr&& other) : pointer_(other.pointer_), counter_(other.counter_)
     249            {
     250                other.pointer_ = nullptr;
     251                other.counter_ = nullptr;
     252            }
     253
    247254            /// Destructor, decrements the counter and deletes the object if the counter becomes zero.
    248255            inline ~SharedPtr()
     
    261268
    262269            /// Assigns a new object, decrements the counter of the old object, increments the counter of the new object.
    263             inline SharedPtr& operator=(const SharedPtr& other)
    264             {
    265                 SharedPtr(other).swap(*this);
     270            inline SharedPtr& operator=(SharedPtr other)
     271            {
     272                other.swap(*this);
    266273                return *this;
    267274            }
Note: See TracChangeset for help on using the changeset viewer.