Skip to content
Snippets Groups Projects
Commit 45eca35b authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Merge branch '5.0.X_v1' into '5.0.X'

Update GeoIntrusivePtr.h

See merge request !264
parents 899a530c d2373620
Branches
Tags 5.0.2
1 merge request!264Update GeoIntrusivePtr.h
Pipeline #6803032 passed
...@@ -15,14 +15,14 @@ class GeoIntrusivePtr{ ...@@ -15,14 +15,14 @@ class GeoIntrusivePtr{
public: public:
template <typename GeoTypeGrp> friend class GeoIntrusivePtr; template <typename GeoTypeGrp> friend class GeoIntrusivePtr;
explicit GeoIntrusivePtr() noexcept = default; GeoIntrusivePtr() noexcept = default;
// Standard constructor taking a bare pointer // Standard constructor taking a bare pointer
GeoIntrusivePtr(GeoType* obj) noexcept: GeoIntrusivePtr(GeoType* obj) noexcept:
m_ptr{obj} { m_ptr{obj} {
if (m_ptr) obj->ref(); if (m_ptr) obj->ref();
} }
/// Copy constructor /// Copy constructor
GeoIntrusivePtr(const GeoIntrusivePtr& other) noexcept: explicit GeoIntrusivePtr(const GeoIntrusivePtr& other) noexcept:
GeoIntrusivePtr{other.get()} {} GeoIntrusivePtr{other.get()} {}
/// Copy constructor for derived types /// Copy constructor for derived types
...@@ -50,6 +50,13 @@ class GeoIntrusivePtr{ ...@@ -50,6 +50,13 @@ class GeoIntrusivePtr{
reset(other.get()); reset(other.get());
return *this; return *this;
} }
template <typename GeoTypeGrp,
typename = typename std::enable_if<!std::is_same<GeoType,GeoTypeGrp>::value, bool>>
GeoIntrusivePtr& operator=(const GeoIntrusivePtr<GeoTypeGrp>& other) {
reset(other.get());
return *this;
}
GeoIntrusivePtr& operator=(GeoType* other) noexcept { GeoIntrusivePtr& operator=(GeoType* other) noexcept {
reset(other); reset(other);
return *this; return *this;
...@@ -66,7 +73,7 @@ class GeoIntrusivePtr{ ...@@ -66,7 +73,7 @@ class GeoIntrusivePtr{
} }
template <typename GeoTypeGrp, template <typename GeoTypeGrp,
typename = typename std::enable_if<!std::is_same<GeoType,GeoTypeGrp>::value, bool>> typename = typename std::enable_if<!std::is_same<GeoType,GeoTypeGrp>::value, bool>>
GeoIntrusivePtr& operator=(GeoIntrusivePtr<GeoTypeGrp>&& other) { GeoIntrusivePtr& operator=(GeoIntrusivePtr<GeoTypeGrp>&& other) {
if (m_ptr && m_ptr == other.get()) { if (m_ptr && m_ptr == other.get()) {
m_ptr->unref(); m_ptr->unref();
} else { } else {
...@@ -104,7 +111,7 @@ class GeoIntrusivePtr{ ...@@ -104,7 +111,7 @@ class GeoIntrusivePtr{
template <class GeoTypeGrp> template <class GeoTypeGrp>
bool operator==(const GeoIntrusivePtr<GeoTypeGrp>& other) const { bool operator==(const GeoIntrusivePtr<GeoTypeGrp>& other) const {
return m_ptr == other.m_ptr; return m_ptr == other.m_ptr;
} }
bool operator==(GeoType* other) const { bool operator==(GeoType* other) const {
return m_ptr == other; return m_ptr == other;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment