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

Update GeoIntrusivePtr.h

parent 899a530c
No related branches found
No related tags found
1 merge request!264Update GeoIntrusivePtr.h
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment