Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/object/ClassFactory.h

    r9667 r11071  
    5353    {
    5454        public:
    55             virtual ~Factory() {}
     55            Factory() = default;
     56            virtual ~Factory() = default;
    5657            virtual Identifiable* fabricate(Context* context) = 0;
    5758    };
  • code/trunk/src/libraries/core/object/Context.cc

    r10624 r11071  
    4040    RegisterClass(Context);
    4141
    42     Context* Context::rootContext_s = 0;
     42    Context* Context::rootContext_s = nullptr;
    4343
    4444    Context* getContextForInitializationOfOtherContexts()
     
    4646        static size_t count = 0;
    4747        // the first time this is called, ++count returns 1 and the context is created
    48         // the second time this is called, ++count returns 2 and NULL is returned because we're in the constructor of the context itself
     48        // the second time this is called, ++count returns 2 and nullptr is returned because we're in the constructor of the context itself
    4949        // for each future call the context (now completely created) is returned
    5050        if (++count == 2)
    51             return NULL;
     51            return nullptr;
    5252        else
    5353        {
    54             static Context context(NULL);
     54            static Context context(nullptr);
    5555            return &context;
    5656        }
     
    7070        // unregister context from object lists before object lists are destroyed
    7171        this->unregisterObject();
    72         for (size_t i = 0; i < this->objectLists_.size(); ++i)
    73             delete this->objectLists_[i];
     72        for (ObjectListBase* objectList : this->objectLists_)
     73            delete objectList;
    7474    }
    7575
     
    8282    {
    8383        delete Context::rootContext_s;
    84         Context::rootContext_s = NULL;
     84        Context::rootContext_s = nullptr;
    8585    }
    8686
    8787    /*static*/ Context* Context::getRootContext()
    8888    {
    89         OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined");
     89        OrxVerify(Context::rootContext_s != nullptr, "Root Context is undefined");
    9090        return Context::rootContext_s;
    9191    }
     
    105105        ObjectListBase* objectList = this->getObjectList(identifier);
    106106        delete objectList;
    107         this->objectLists_[identifier->getClassID()] = NULL;
     107        this->objectLists_[identifier->getClassID()] = nullptr;
    108108    }
    109109}
  • code/trunk/src/libraries/core/object/DestroyLaterManager.h

    r10624 r11071  
    4545            virtual ~DestroyLaterManager();
    4646
    47             virtual void preUpdate(const Clock& time) { /*no action*/ }
    48             virtual void postUpdate(const Clock& time);
     47            virtual void preUpdate(const Clock& time) override { /*no action*/ }
     48            virtual void postUpdate(const Clock& time) override;
    4949
    5050            void retain(Destroyable* instance)
     
    5252
    5353        private:
    54             std::vector<StrongPtr<Destroyable> > retainedInstances_;
     54            std::vector<StrongPtr<Destroyable>> retainedInstances_;
    5555
    5656            static DestroyLaterManager* singletonPtr_s;
  • code/trunk/src/libraries/core/object/Destroyable.cc

    r11019 r11071  
    5454    Destroyable::~Destroyable()
    5555    {
    56         if (!this->requestedDestruction_ && !IdentifierManager::getInstance().isCreatingHierarchy())
     56        if (!this->requestedDestruction_ && IdentifierManager::exists() && !IdentifierManager::getInstance().isCreatingHierarchy())
    5757            orxout(internal_warning) << "Deleted destroyable object without destroy()" << endl;
    5858
     
    7070    void Destroyable::destroy()
    7171    {
    72         assert(this); // Just in case someone tries to delete a NULL pointer
     72        assert(this); // Just in case someone tries to delete a nullptr
    7373        this->requestedDestruction_ = true;
    7474        if (this->referenceCount_ == 0)
  • code/trunk/src/libraries/core/object/Iterator.h

    r10624 r11071  
    7070    */
    7171    template <class T>
    72     class Iterator : public IteratorBase<T, Iterator<T> >
     72    class Iterator : public IteratorBase<T, Iterator<T>>
    7373    {
    7474        public:
     
    7676                @brief Constructor: Sets the element, whereon the iterator points, to zero.
    7777            */
    78             inline Iterator() : IteratorBase<T, Iterator<T> >() {}
    79 
    80             /**
    81                 @brief Constructor: Sets this element to a given element
    82                 @param element The element
    83             */
    84             inline Iterator(ObjectListBaseElement* element) : IteratorBase<T, Iterator<T> >(element) {}
     78            inline Iterator() : IteratorBase<T, Iterator<T>>() {}
    8579
    8680            /**
     
    8882                @param other The other Iterator
    8983            */
    90             inline Iterator(const IteratorBase<T, Iterator<T> >& other) : IteratorBase<T, Iterator<T> >(other) {}
     84            template <class OT, class OI>
     85            inline Iterator(const IteratorBase<OT, OI>& other) : IteratorBase<T, Iterator<T>>(other) {}
    9186
    9287            /**
  • code/trunk/src/libraries/core/object/IteratorBase.h

    r10624 r11071  
    3737
    3838#include "core/CorePrereqs.h"
    39 
    40 #include <boost/static_assert.hpp>
    41 #include <boost/type_traits/is_base_of.hpp>
    4239
    4340#include "ObjectListBase.h"
     
    5249    class IteratorBase : public ObjectListElementRemovalListener
    5350    {
    54         BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
    55 
    56         protected:
     51        static_assert(std::is_base_of<Listable, T>::value, "IteratorBase can only be used with Listables");
     52
     53        public:
    5754            /**
    5855                @brief Constructor: Sets the element, whereon the iterator points, to the given element.
    59                 This constructor is protected and only for internal usage (don't mess with the BaseElements directly).
    60             */
    61             inline IteratorBase(ObjectListBaseElement* element = NULL)
     56            */
     57            inline IteratorBase(ObjectListElement<T>* element = nullptr)
    6258            {
    6359                this->element_ = element;
     
    6561            }
    6662
    67 
    68         public:
    69             /**
    70                 @brief Constructor: Sets the element, whereon the iterator points, to the given element.
    71             */
    72             inline IteratorBase(ObjectListElement<T>* element)
    73             {
    74                 this->element_ = element;
    75                 this->registerIterator();
    76             }
    77 
    7863            /**
    7964                @brief Constructor: Sets the element, whereon the iterator points, to the given element of another type.
    8065                The element's type O must be a derivative of the Iterator's type T.
    8166            */
    82             template <class O>
    83             inline IteratorBase(ObjectListElement<O>* element)
    84             {
    85                 (void)static_cast<T*>((O*)NULL); // Check type: The element's type O must be a derivative of the Iterator's type T.
    86                 this->element_ = element;
    87                 this->registerIterator();
    88             }
    89 
    90             /**
    91                 @brief Constructor: Sets this element to the element of another Iterator.
    92                 @param other The other Iterator
    93             */
    94             inline IteratorBase(const IteratorBase& other)
    95             {
    96                 this->element_ = other.element_;
     67            template <class OT, class OI>
     68            inline IteratorBase(const IteratorBase<OT, OI>& other)
     69            {
     70                this->element_ = other.getElement();
    9771                this->registerIterator();
    9872            }
     
    172146                @return True if the Iterator points to an existing object.
    173147            */
    174             inline operator bool() const
    175             {
    176                 return (this->element_ != NULL);
     148            inline explicit operator bool() const
     149            {
     150                return (this->element_ != nullptr);
    177151            }
    178152
     
    201175                @param object The object to compare with
    202176            */
    203             virtual void removedElement(ObjectListBaseElement* element)
     177            virtual void removedElement(ObjectListBaseElement* element) override
    204178            {
    205179                if (this->element_ == element)
    206180                    this->operator++();
     181            }
     182
     183            inline ObjectListBaseElement* getElement() const
     184            {
     185                return this->element_;
    207186            }
    208187
     
    226205                }
    227206                else
    228                     this->list_ = NULL;
     207                    this->list_ = nullptr;
    229208            }
    230209
  • code/trunk/src/libraries/core/object/Listable.cc

    r10624 r11071  
    4444        @brief Constructor: Allocates space in the element list.
    4545    */
    46     Listable::Listable()
     46    Listable::Listable() : Listable(Context::getRootContext())
    4747    {
    48         this->context_ = Context::getRootContext();
    49         this->elements_.reserve(6);
    50 
    51         RegisterObject(Listable);
    5248    }
    5349
     
    7672    void Listable::unregisterObject()
    7773    {
    78         for (size_t i = 0; i < this->elements_.size(); ++i)
    79             Listable::deleteObjectListElement(this->elements_[i]);
     74        for (ObjectListBaseElement* element : this->elements_)
     75            Listable::deleteObjectListElement(element);
    8076        this->elements_.clear();
    8177    }
     
    9187        this->elements_.clear();
    9288
    93         for (size_t i = 0; i < copy.size(); ++i)
     89        for (ObjectListBaseElement* element : copy)
    9490        {
    95             copy[i]->changeContext(this->context_, context);
    96             Listable::deleteObjectListElement(copy[i]);
     91            element->changeContext(this->context_, context);
     92            Listable::deleteObjectListElement(element);
    9793        }
    9894
  • code/trunk/src/libraries/core/object/Listable.h

    r9667 r11071  
    4040#include <vector>
    4141
     42#include "util/SmallObjectAllocator.h"
    4243#include "core/class/Identifiable.h"
    4344
  • code/trunk/src/libraries/core/object/ObjectList.h

    r10624 r11071  
    4747#include "core/CorePrereqs.h"
    4848
    49 #include <boost/static_assert.hpp>
    50 #include <boost/type_traits/is_base_of.hpp>
    51 
    5249#include "ObjectListBase.h"
    5350#include "ObjectListIterator.h"
     
    6966    class ObjectList
    7067    {
    71         BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
     68        static_assert(std::is_base_of<Listable, T>::value, "ObjectList can only be used with Listables");
    7269
    7370        public:
    7471            typedef ObjectListIterator<T> iterator;
    7572
    76             /// Returns the size of the list (for the root context)
    77             inline static size_t size()
    78             {   return size(Context::getRootContext());   }
     73            ObjectList() : ObjectList(Context::getRootContext()) {}
     74            ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {}
     75            ObjectList(ObjectListBase* list) : list_(list) {}
     76
    7977            /// Returns the size of the list
    80             inline static size_t size(Context* context)
    81             {
    82                 return context->getObjectList<T>()->size();
    83             }
     78            inline size_t size()
     79            {   return this->list_->size();   }
    8480
    85             /// Returns an Iterator to the first element in the list (for the root context).
    86             inline static ObjectListElement<T>* begin()
    87             {   return begin(Context::getRootContext());   }
    8881            /// Returns an Iterator to the first element in the list.
    89             inline static ObjectListElement<T>* begin(Context* context)
    90             {
    91                 ObjectListBase* list = context->getObjectList<T>();
    92                 return static_cast<ObjectListElement<T>*>(list->begin());
    93             }
     82            inline ObjectListIterator<T> begin()
     83            {   return static_cast<ObjectListElement<T>*>(this->list_->begin());   }
     84            /// Returns an Iterator to the element after the last element in the list.
     85            inline ObjectListIterator<T> end()
     86            {   return static_cast<ObjectListElement<T>*>(this->list_->end());   }
    9487
    95             /// Returns an Iterator to the element after the last element in the list (for the root context).
    96             inline static ObjectListElement<T>* end()
    97             {   return end(Context::getRootContext());   }
    98             /// Returns an Iterator to the element after the last element in the list.
    99             inline static ObjectListElement<T>* end(Context* context)
    100             {
    101                 ObjectListBase* list = context->getObjectList<T>();
    102                 return static_cast<ObjectListElement<T>*>(list->end());
    103             }
     88            /// Returns an Iterator to the last element in the list.
     89            inline ObjectListIterator<T> rbegin()
     90            {   return static_cast<ObjectListElement<T>*>(this->list_->rbegin());   }
     91            /// Returns an Iterator to the element before the first element in the list.
     92            inline ObjectListIterator<T> rend()
     93            {   return static_cast<ObjectListElement<T>*>(this->list_->rend());   }
    10494
    105             /// Returns an Iterator to the last element in the list (for the root context).
    106             inline static ObjectListElement<T>* rbegin()
    107             {   return rbegin(Context::getRootContext());   }
    108             /// Returns an Iterator to the last element in the list.
    109             inline static ObjectListElement<T>* rbegin(Context* context)
    110             {
    111                 ObjectListBase* list = context->getObjectList<T>();
    112                 return static_cast<ObjectListElement<T>*>(list->rbegin());
    113             }
    114 
    115             /// Returns an Iterator to the element before the first element in the list (for the root context).
    116             inline static ObjectListElement<T>* rend()
    117             {   return rend(Context::getRootContext());   }
    118             /// Returns an Iterator to the element before the first element in the list.
    119             inline static ObjectListElement<T>* rend(Context* context)
    120             {
    121                 ObjectListBase* list = context->getObjectList<T>();
    122                 return static_cast<ObjectListElement<T>*>(list->rend());
    123             }
     95        private:
     96            ObjectListBase* list_;
    12497    };
    12598}
  • code/trunk/src/libraries/core/object/ObjectListBase.cc

    r9975 r11071  
    5858    ObjectListBase::ObjectListBase()
    5959    {
    60         this->first_ = 0;
    61         this->last_ = 0;
     60        this->first_ = nullptr;
     61        this->last_ = nullptr;
    6262        this->size_ = 0;
    6363    }
     
    7373            ObjectListBaseElement* next = current->next_;
    7474
    75             current->list_ = 0;
    76             current->next_ = 0;
    77             current->prev_ = 0;
     75            current->list_ = nullptr;
     76            current->next_ = nullptr;
     77            current->prev_ = nullptr;
    7878
    7979            current = next;
     
    9292    void ObjectListBase::notifyRemovalListeners(ObjectListBaseElement* element) const
    9393    {
    94         for (std::vector<ObjectListElementRemovalListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    95             (*it)->removedElement(element);
     94        for (ObjectListElementRemovalListener* listener : this->listeners_)
     95            listener->removedElement(element);
    9696    }
    9797
     
    155155            this->first_ = element->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
    156156
    157         element->list_ = 0;
    158         element->next_ = 0;
    159         element->prev_ = 0;
     157        element->list_ = nullptr;
     158        element->next_ = nullptr;
     159        element->prev_ = nullptr;
    160160        --this->size_;
    161161    }
  • code/trunk/src/libraries/core/object/ObjectListBase.h

    r9667 r11071  
    5757                @param objectBase The object to store
    5858            */
    59             ObjectListBaseElement(Listable* object) : next_(0), prev_(0), objectBase_(object), list_(0) {}
     59            ObjectListBaseElement(Listable* object) : next_(nullptr), prev_(nullptr), objectBase_(object), list_(nullptr) {}
    6060            virtual ~ObjectListBaseElement() { this->removeFromList(); }
    6161
     
    8282            ObjectListElement(T* object) : ObjectListBaseElement(static_cast<Listable*>(object)), object_(object) {}
    8383
    84             virtual void changeContext(Context* oldContext, Context* newContext)
     84            virtual void changeContext(Context* oldContext, Context* newContext) override
    8585            {
    8686                // add object to new context, but only if this element belongs exactly to the old context (and not to a sub-context to avoid re-adding objects
     
    104104    {
    105105        public:
    106             virtual ~ObjectListElementRemovalListener() {}
     106            ObjectListElementRemovalListener() = default;
     107            virtual ~ObjectListElementRemovalListener() = default;
    107108            virtual void removedElement(ObjectListBaseElement* element) = 0;
    108109    };
     
    136137            inline ObjectListBaseElement* begin() const { return this->first_; }
    137138            /// Returns a pointer to the element after the last element in the list. Works only with Iterator.
    138             inline ObjectListBaseElement* end() const { return 0; }
     139            inline ObjectListBaseElement* end() const { return nullptr; }
    139140            /// Returns a pointer to the last element in the list. Works only with Iterator.
    140141            inline ObjectListBaseElement* rbegin() const { return this->last_; }
    141142            /// Returns a pointer to the element in front of the first element in the list. Works only with Iterator.
    142             inline ObjectListBaseElement* rend() const { return 0; }
     143            inline ObjectListBaseElement* rend() const { return nullptr; }
    143144
    144145            inline void registerRemovalListener(ObjectListElementRemovalListener* listener) { this->listeners_.push_back(listener); }
  • code/trunk/src/libraries/core/object/ObjectListIterator.h

    r10624 r11071  
    4141    Usage:
    4242    @code
    43     for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
     43    ObjectList<myClass> list;
     44    for (ObjectListIterator<myClass> it = list.begin(); it != list.end(); ++it)
    4445    {
    4546        it->someFunction(...);
     
    6869    */
    6970    template <class T>
    70     class ObjectListIterator : public IteratorBase<T, ObjectListIterator<T> >
     71    class ObjectListIterator : public IteratorBase<T, ObjectListIterator<T>>
    7172    {
    7273        public:
     
    7475                @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
    7576            */
    76             inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >() {}
     77            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T>>() {}
    7778
    7879            /**
     
    8081                @param element The element to start with
    8182            */
    82             inline ObjectListIterator(ObjectListElement<T>* element) : IteratorBase<T, ObjectListIterator<T> >(element) {}
     83            inline ObjectListIterator(ObjectListElement<T>* element) : IteratorBase<T, ObjectListIterator<T>>(element) {}
    8384
    8485            /**
     
    8687                @param other The other ObjectListIterator
    8788            */
    88             inline ObjectListIterator(const IteratorBase<T, ObjectListIterator<T> >& other) : IteratorBase<T, ObjectListIterator<T> >(other) {}
     89            template <class OI>
     90            inline ObjectListIterator(const IteratorBase<T, OI>& other) : IteratorBase<T, ObjectListIterator<T>>(other) {}
    8991
    9092            /**
  • code/trunk/src/libraries/core/object/StrongPtr.h

    r10624 r11071  
    4343    orxonox::StrongPtr is an implementation of a smart pointer - it wraps a pointer to an
    4444    object  and keeps this object alive until no StrongPtr points to this object anymore.
    45     In contrast to orxonox::SharedPtr, StrongPtr works only with classes that are derived
     45    In contrast to std::shared_ptr, StrongPtr works only with classes that are derived
    4646    from orxonox::Destroyable, because it's an intrusive implementation, meaning the
    4747    reference counter is stored in the object itself.
     
    5151    at any time and also convert it back to a normal pointer if you like. This is possible
    5252    because the reference counter is stored in the object itself and not in StrongPtr (in
    53     contrast to SharedPtr).
     53    contrast to std::shared_ptr).
    5454
    5555    @b Important: If you want to delete an object, you must not use @c delete @c object but
     
    138138        public:
    139139            /// Constructor: Initializes the strong pointer with a null pointer.
    140             inline StrongPtr() : pointer_(0), base_(0)
     140            inline StrongPtr() : pointer_(nullptr), base_(nullptr)
    141141            {
    142142            }
     
    158158            /// Copy-constructor for strong pointers to objects of another class.
    159159            template <class O>
    160             inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.base_)
     160            inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.getBase())
    161161            {
    162162                if (this->base_)
     
    172172            }
    173173
     174            /// Move-constructor
     175            inline StrongPtr(StrongPtr&& other) : pointer_(other.pointer_), base_(other.base_)
     176            {
     177                other.pointer_ = nullptr;
     178                other.base_ = nullptr;
     179            }
     180
    174181            /// Destructor: Decrements the reference counter.
    175182            inline ~StrongPtr()
     
    187194
    188195            /// Assigns the wrapped pointer of another StrongPtr.
    189             inline StrongPtr& operator=(const StrongPtr& other)
    190             {
    191                 StrongPtr(other).swap(*this);
     196            inline StrongPtr& operator=(StrongPtr other)
     197            {
     198                other.swap(*this);
    192199                return *this;
    193200            }
     
    230237            inline T* operator->() const
    231238            {
    232                 assert(this->pointer_ != 0);
     239                assert(this->pointer_ != nullptr);
    233240                return this->pointer_;
    234241            }
     
    237244            inline T& operator*() const
    238245            {
    239                 assert(this->pointer_ != 0);
     246                assert(this->pointer_ != nullptr);
    240247                return *this->pointer_;
    241248            }
    242249
    243             /// Returns true if the wrapped pointer is NULL.
    244             inline bool operator!() const
    245             {
    246                 return (this->pointer_ == 0);
     250            /// Returns true if the pointer is not nullptr.
     251            inline explicit operator bool() const
     252            {
     253                return (this->pointer_ != nullptr);
    247254            }
    248255
     
    262269            }
    263270
    264             /// Resets the strong pointer (equivalent to assigning a NULL pointer).
     271            /// Resets the strong pointer (equivalent to assigning a nullptr).
    265272            inline void reset()
    266273            {
  • code/trunk/src/libraries/core/object/WeakPtr.h

    r10624 r11071  
    3737
    3838    A WeakPtr wraps a pointer to an object. If the object gets deleted, the WeakPtr becomes
    39     NULL. This can be used to store pointers to objects without knowing when they will be
     39    nullptr. This can be used to store pointers to objects without knowing when they will be
    4040    destroyed.
    4141
     
    5050    WeakPtr<MyClass> pointer = object;                  // create a WeakPtr and assign the object
    5151
    52     if (pointer)                                        // checks if pointer is not NULL (which is true)
     52    if (pointer)                                        // checks if pointer is not nullptr (which is true)
    5353        pointer->someFunction();                        // calls MyClass::someFunction()
    5454
    5555    object->destroy();                                  // calls destroy() which deletes the object
    5656
    57     if (pointer)                                        // checks if pointer is not NULL (which is now false)
     57    if (pointer)                                        // checks if pointer is not nullptr (which is now false)
    5858        pointer->someFunction();                        // this will not be executed
    5959    @endcode
     
    9191{
    9292    /**
    93         @brief WeakPtr wraps a pointer to an object, which becomes NULL if the object is deleted.
     93        @brief WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
    9494
    9595        @see See @ref WeakPtrExample "this description" for more information and an example.
     
    100100        public:
    101101            /// Constructor: Initializes the weak pointer with a null pointer.
    102             inline WeakPtr() : pointer_(0), base_(0), callback_(0)
     102            inline WeakPtr() : pointer_(nullptr), base_(nullptr), callback_(nullptr)
    103103            {
    104104            }
    105105
    106106            /// Constructor: Initializes the weak pointer with a pointer to an object.
    107             inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0)
     107            inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(nullptr)
    108108            {
    109109                this->registerAsDestructionListener(this->base_);
     
    111111
    112112            /// Copy-constructor
    113             inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_(0)
     113            inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_(nullptr)
    114114            {
    115115                this->registerAsDestructionListener(this->base_);
     
    118118            /// Copy-constructor for weak pointers to objects of another class.
    119119            template <class O>
    120             inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.base_), callback_(0)
     120            inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase()), callback_(nullptr)
    121121            {
    122122                this->registerAsDestructionListener(this->base_);
     
    124124
    125125            /// Destructor
    126             inline virtual ~WeakPtr()
     126            virtual inline ~WeakPtr()
    127127            {
    128128                this->unregisterAsDestructionListener(this->base_);
     
    137137
    138138            /// Assigns the wrapped pointer of another WeakPtr.
    139             inline WeakPtr& operator=(const WeakPtr& other)
    140             {
    141                 WeakPtr(other).swap(*this);
     139            inline WeakPtr& operator=(WeakPtr other)
     140            {
     141                other.swap(*this);
    142142                return *this;
    143143            }
     
    172172            inline T* operator->() const
    173173            {
    174                 assert(this->pointer_ != 0);
     174                assert(this->pointer_ != nullptr);
    175175                return this->pointer_;
    176176            }
     
    179179            inline T& operator*() const
    180180            {
    181                 assert(this->pointer_ != 0);
     181                assert(this->pointer_ != nullptr);
    182182                return *this->pointer_;
    183183            }
    184184
    185             /// Returns true if the wrapped pointer is NULL.
    186             inline bool operator!() const
    187             {
    188                 return (this->pointer_ == 0);
     185            /// Returns true if the pointer is not nullptr.
     186            inline explicit operator bool() const
     187            {
     188                return (this->pointer_ != nullptr);
    189189            }
    190190
     
    210210            }
    211211
    212             /// Resets the weak pointer (equivalent to assigning a NULL pointer).
     212            /// Resets the weak pointer (equivalent to assigning a nullptr).
    213213            inline void reset()
    214214            {
     
    230230        private:
    231231            /// Will be called by Destroyable::~Destroyable() if the stored object is deleted. Resets the wrapped pointer and executes the callback.
    232             inline void objectDeleted()
    233             {
    234                 this->base_ = 0;
    235                 this->pointer_ = 0;
     232            virtual inline void objectDeleted() override
     233            {
     234                this->base_ = nullptr;
     235                this->pointer_ = nullptr;
    236236                if (this->callback_)
    237237                    (*this->callback_)();
Note: See TracChangeset for help on using the changeset viewer.