Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=1c317890d22c8b6019aa8542ca5b11876d3479e5

commit 1c317890d22c8b6019aa8542ca5b11876d3479e5
Author: Michel Hermier <herm...@frugalware.org>
Date:   Sat Oct 18 12:09:07 2014 +0200

libpacman: Make refcounted_ptr a little bit more usefull/usable.

diff --git a/lib/libpacman/kernel/frefcounted.h 
b/lib/libpacman/kernel/frefcounted.h
index 64f95ba..c5c9921 100644
--- a/lib/libpacman/kernel/frefcounted.h
+++ b/lib/libpacman/kernel/frefcounted.h
@@ -71,6 +71,10 @@ namespace flib
typedef T element_type;

constexpr refcounted_ptr()
+                       : refcounted_ptr(nullptr)
+               { }
+
+               constexpr refcounted_ptr(std::nullptr_t)
: m_refcounted_ptr(nullptr)
{ }

@@ -83,6 +87,11 @@ namespace flib
}
}

+               template <class Y>
+               refcounted_ptr(const refcounted_ptr<Y> &o)
+                       : refcounted_ptr(o.m_refcounted_ptr)
+               { }
+
~refcounted_ptr()
{
if(m_refcounted_ptr != nullptr) {
@@ -90,6 +99,13 @@ namespace flib
}
}

+               template <class Y>
+               refcounted_ptr<Y> &operator = (const refcounted_ptr<Y> &o)
+               {
+                       reset(o.m_refcounted_ptr);
+                       return *this;
+               }
+
/* Manipulators */
void reset()
{
@@ -102,7 +118,7 @@ namespace flib
swap(*this, refcounted_ptr<T>(ptr));
}

-               void swap(refcounted_ptr &o)
+               void swap(refcounted_ptr<T> &o)
{
std::swap(m_refcounted_ptr, o.m_refcounted_ptr);
}
@@ -139,6 +155,18 @@ namespace flib
};
}

+template <class T, class U>
+bool operator == (const flib::refcounted_ptr<T> &lhs, const 
flib::refcounted_ptr<U> &rhs)
+{
+       return lhs.get() == rhs.get();
+}
+
+template <class T, class U>
+bool operator != (const flib::refcounted_ptr<T> &lhs, const 
flib::refcounted_ptr<U> &rhs)
+{
+       return lhs.get() != rhs.get();
+}
+
#endif /* FREFCOUNTED_H */

/* vim: set ts=2 sw=2 noet: */
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to