Skip to content
Snippets Groups Projects

Update GeoIntrusivePtr.h

Merged Johannes Junggeburth requested to merge 5.0.X_v1 into 5.0.X
All threads resolved!
1 file
+ 11
4
Compare changes
  • Side-by-side
  • Inline
@@ -15,14 +15,14 @@ class GeoIntrusivePtr{
public:
template <typename GeoTypeGrp> friend class GeoIntrusivePtr;
explicit GeoIntrusivePtr() noexcept = default;
GeoIntrusivePtr() noexcept = default;
// Standard constructor taking a bare pointer
GeoIntrusivePtr(GeoType* obj) noexcept:
m_ptr{obj} {
if (m_ptr) obj->ref();
}
/// Copy constructor
GeoIntrusivePtr(const GeoIntrusivePtr& other) noexcept:
explicit GeoIntrusivePtr(const GeoIntrusivePtr& other) noexcept:
GeoIntrusivePtr{other.get()} {}
/// Copy constructor for derived types
@@ -50,6 +50,13 @@ class GeoIntrusivePtr{
reset(other.get());
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 {
reset(other);
return *this;
@@ -66,7 +73,7 @@ class GeoIntrusivePtr{
}
template <typename GeoTypeGrp,
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()) {
m_ptr->unref();
} else {
@@ -104,7 +111,7 @@ class GeoIntrusivePtr{
template <class GeoTypeGrp>
bool operator==(const GeoIntrusivePtr<GeoTypeGrp>& other) const {
return m_ptr == other.m_ptr;
}
}
bool operator==(GeoType* other) const {
return m_ptr == other;
}
Loading