Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into jmigual-library-r…
Browse files Browse the repository at this point in the history
…edesign
  • Loading branch information
daschuer committed Feb 18, 2017
2 parents 4cb8274 + 5a7df99 commit a9716b9
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions src/util/parented_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ class parented_ptr {
return m_pObject;
}

bool operator== (const parented_ptr& other) const {
return m_pObject == other.m_pObject;
}

bool operator== (const T* other) const {
return m_pObject == other;
}

bool operator!= (const parented_ptr& other) const {
return m_pObject != other.m_pObject;
}

bool operator!= (const T* other) const {
return m_pObject != other;
}

operator bool() const {
return m_pObject != nullptr;
}
Expand Down Expand Up @@ -104,6 +88,37 @@ inline parented_ptr<T> make_parented(Args&&... args) {
return parented_ptr<T>(new T(std::forward<Args>(args)...));
}

// Comparison operator definitions
template<typename T, typename U>
inline bool operator== (const T* lhs, const parented_ptr<U>& rhs) {
return lhs == rhs.get();
}

template<typename T, typename U>
inline bool operator== (const parented_ptr<T>& lhs, const U* rhs) {
return lhs.get() == rhs;
}

template<typename T, typename U>
inline bool operator== (const parented_ptr<T>& lhs, const parented_ptr<U>& rhs) const {
return lhs.get() == rhs.get();
}

template<typename T, typename U>
inline bool operator!= (const T* lhs, const parented_ptr<U>& rhs) {
return !(lhs == rhs.get());
}

template<typename T, typename U>
inline bool operator!= (const parented_ptr<T>& lhs, const U* rhs) {
return !(lhs.get() == rhs);
}

template<typename T, typename U>
inline bool operator!= (const parented_ptr<T>& lhs, const parented_ptr<U>& rhs) const {
return !(lhs.get() == rhs.get());
}

} // namespace

#endif // UTIL_PARENTED_PTR_H

0 comments on commit a9716b9

Please sign in to comment.