@@ -96,14 +96,10 @@ template <class T> class GameObjectPtr {
9696 // / game element held by this object and throws an exception if the object is the
9797 // / null object, or is no longer valid (has been removed from the game)
9898 // /
99- // / @exception NullException if the object holds a reference to a null element
10099 // / @exception InvalidObjectException if the element referred to has been deleted from its game
101100 std::shared_ptr<T> get_shared () const
102101 {
103- if (!m_rep) {
104- throw NullException ();
105- }
106- if (!m_rep->IsValid ()) {
102+ if (m_rep && !m_rep->IsValid ()) {
107103 throw InvalidObjectException ();
108104 }
109105 return m_rep;
@@ -129,16 +125,16 @@ template <class T> class GameObjectPtr {
129125 }
130126
131127 bool operator ==(const GameObjectPtr<T> &r) const { return (m_rep == r.m_rep ); }
132- bool operator ==(const std::shared_ptr<T> r) const { return (m_rep == r); }
133- bool operator ==(const std::shared_ptr<const T> r) const { return (m_rep == r); }
134- bool operator ==(const std::nullptr_t ) const { return ! bool ( m_rep) ; }
128+ bool operator ==(const std::shared_ptr<T> & r) const { return (m_rep == r); }
129+ bool operator ==(const std::shared_ptr<const T> & r) const { return (m_rep == r); }
130+ bool operator ==(const std::nullptr_t & ) const { return m_rep == nullptr ; }
135131 bool operator !=(const GameObjectPtr<T> &r) const { return (m_rep != r.m_rep ); }
136- bool operator !=(const std::shared_ptr<T> r) const { return (m_rep != r); }
137- bool operator !=(const std::shared_ptr<const T> r) const { return (m_rep != r); }
138- bool operator !=(const std::nullptr_t ) const { return bool ( m_rep) ; }
132+ bool operator !=(const std::shared_ptr<T> & r) const { return (m_rep != r); }
133+ bool operator !=(const std::shared_ptr<const T> & r) const { return (m_rep != r); }
134+ bool operator !=(const std::nullptr_t & ) const { return m_rep != nullptr ; }
139135 bool operator <(const GameObjectPtr<T> &r) const { return (m_rep < r.m_rep ); }
140136
141- operator bool () const noexcept { return bool ( m_rep) ; }
137+ operator bool () const noexcept { return m_rep != nullptr ; }
142138 operator std::shared_ptr<T>() const { return m_rep; }
143139};
144140
0 commit comments