summaryrefslogtreecommitdiff
path: root/include/vcl/vclptr.hxx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-04-13 21:19:21 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-04-13 21:25:36 +0100
commit324377ada2513031e211f1d38a842859b6f094a2 (patch)
tree1b42a93451be85c93c47eac794481eed284dcfdf /include/vcl/vclptr.hxx
parent5245021a806ccdd0d569d5cee7b95167892e9aab (diff)
VclPtr - add a templatized ::Create method for better readability.
Change-Id: I2437198709ba4848d975efd1ebb4df1071c6c8f1
Diffstat (limited to 'include/vcl/vclptr.hxx')
-rw-r--r--include/vcl/vclptr.hxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index c4c210b5b451..d97124d92d65 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -125,6 +125,20 @@ public:
{
}
+ /**
+ * A construction helper for VclPtr. Since VclPtr types are created
+ * with a reference-count of one - to help fit into the existing
+ * code-flow; this helps us to construct them easily.
+ *
+ * For more details on the design please see vcl/README.lifecycle
+ *
+ * @param reference_type must be a subclass of vcl::Window
+ */
+ template<typename... Arg> static VclPtr< reference_type > Create(Arg &&... arg)
+ {
+ return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE );
+ }
+
/** Probably most common used: handle->someBodyOp().
*/
inline reference_type * SAL_CALL operator->() const
@@ -224,9 +238,10 @@ public:
}; // class VclPtr
/**
- * A construction helper for VclPtr. Since VclPtr types are created
- * with a reference-count of one - to help fit into the existing
- * code-flow; this helps us to construct them easily.
+ * A construction helper for a temporary VclPtr. Since VclPtr types
+ * are created with a reference-count of one - to help fit into
+ * the existing code-flow; this helps us to construct them easily.
+ * see also VclPtr::Create and ScopedVclPtr
*
* For more details on the design please see vcl/README.lifecycle
*
@@ -295,6 +310,7 @@ public:
VclPtr<reference_type>::disposeAndClear();
assert(VclPtr<reference_type>::get() == nullptr); // make sure there are no lingering references
}
+
private:
// Most likely we don't want this default copy-construtor.
ScopedVclPtr (const ScopedVclPtr<reference_type> &) SAL_DELETED_FUNCTION;