summaryrefslogtreecommitdiff
path: root/include/tools/ref.hxx
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2016-02-21 17:51:28 +0100
committerNoel Grandin <noelgrandin@gmail.com>2016-02-22 12:33:52 +0000
commit14420e83296fd393cba956047370564c3517cdae (patch)
tree9c566a9de39f81a85885f565ce46781857fe7956 /include/tools/ref.hxx
parent1b287f14b2adc79586ae2dde6b08cd8eb960e0ce (diff)
BASIC : Add tools::make_ref and simplify SvRef usage
Change-Id: I8fe846dbd353bace05a8732a9b961f3507d97ef8 Reviewed-on: https://gerrit.libreoffice.org/22587 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'include/tools/ref.hxx')
-rw-r--r--include/tools/ref.hxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index a16125433dda..f9c2c384c37e 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
#include <cassert>
#include <tools/toolsdllapi.h>
+#include <utility>
/**
This implements similar functionality to boost::intrusive_ptr
@@ -32,7 +33,13 @@ namespace tools {
/** T must be a class that extends SvRefBase */
template<typename T> class SAL_DLLPUBLIC_RTTI SvRef {
public:
- SvRef(): pObj(0) {}
+ SvRef(): pObj(nullptr) {}
+
+ SvRef(SvRef&& rObj)
+ {
+ pObj = rObj.pObj;
+ rObj.pObj = nullptr;
+ }
SvRef(SvRef const & rObj): pObj(rObj.pObj)
{
@@ -87,6 +94,15 @@ protected:
T * pObj;
};
+/**
+ * This implements similar functionality to std::make_shared.
+ */
+template<typename T, typename... Args>
+SvRef<T> make_ref(Args&& ... args)
+{
+ return SvRef<T>(new T(std::forward<Args>(args)...));
+}
+
}
/** Classes that want to be referenced-counted via SvRef<T>, should extend this base class */