summaryrefslogtreecommitdiff
path: root/sigc++/weak_raw_ptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'sigc++/weak_raw_ptr.h')
-rw-r--r--sigc++/weak_raw_ptr.h36
1 files changed, 14 insertions, 22 deletions
diff --git a/sigc++/weak_raw_ptr.h b/sigc++/weak_raw_ptr.h
index 816981c..c065242 100644
--- a/sigc++/weak_raw_ptr.h
+++ b/sigc++/weak_raw_ptr.h
@@ -31,24 +31,20 @@ namespace internal
/** T must derive from sigc::trackable.
*/
-template <typename T>
+template<typename T>
struct weak_raw_ptr : public sigc::notifiable
{
- inline weak_raw_ptr()
- : p_(nullptr)
- {}
+ inline weak_raw_ptr() : p_(nullptr) {}
- inline weak_raw_ptr(T* p) noexcept
- : p_(p)
+ inline weak_raw_ptr(T* p) noexcept : p_(p)
{
- if(!p)
+ if (!p)
return;
p->add_destroy_notify_callback(this, &notify_object_invalidated);
}
- inline weak_raw_ptr(const weak_raw_ptr& src) noexcept
- : p_(src.p_)
+ inline weak_raw_ptr(const weak_raw_ptr& src) noexcept : p_(src.p_)
{
if (p_)
p_->add_destroy_notify_callback(this, &notify_object_invalidated);
@@ -56,38 +52,34 @@ struct weak_raw_ptr : public sigc::notifiable
inline weak_raw_ptr& operator=(const weak_raw_ptr& src) noexcept
{
- if(p_) {
+ if (p_)
+ {
p_->remove_destroy_notify_callback(this);
}
p_ = src.p_;
-
+
if (p_)
p_->add_destroy_notify_callback(this, &notify_object_invalidated);
return *this;
}
- //TODO:
+ // TODO:
weak_raw_ptr(weak_raw_ptr&& src) = delete;
weak_raw_ptr& operator=(weak_raw_ptr&& src) = delete;
inline ~weak_raw_ptr() noexcept
{
- if (p_) {
+ if (p_)
+ {
p_->remove_destroy_notify_callback(this);
}
}
- inline explicit operator bool() const noexcept
- {
- return p_ != nullptr;
- }
+ inline explicit operator bool() const noexcept { return p_ != nullptr; }
- inline T* operator->() const noexcept
- {
- return p_;
- }
+ inline T* operator->() const noexcept { return p_; }
private:
/** Callback that is executed when the objet is destroyed.
@@ -96,7 +88,7 @@ private:
static void notify_object_invalidated(notifiable* data)
{
auto self = static_cast<weak_raw_ptr*>(data);
- if(!self)
+ if (!self)
return;
self->p_ = nullptr;