summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/o3tl/cow_wrapper.hxx26
1 files changed, 23 insertions, 3 deletions
diff --git a/include/o3tl/cow_wrapper.hxx b/include/o3tl/cow_wrapper.hxx
index b7659c3a286f..3f117a2b395b 100644
--- a/include/o3tl/cow_wrapper.hxx
+++ b/include/o3tl/cow_wrapper.hxx
@@ -121,7 +121,7 @@ public:
int queryUnmodified() const;
private:
- otl::cow_wrapper< cow_wrapper_client_impl > maImpl;
+ o3tl::cow_wrapper< cow_wrapper_client_impl > maImpl;
};
</pre>
and the implementation file would look like this:
@@ -187,8 +187,8 @@ int cow_wrapper_client::queryUnmodified() const
void release()
{
- if( !MTPolicy::decrementCount(m_pimpl->m_ref_count) )
- boost::checked_delete(m_pimpl), m_pimpl=0;
+ if( m_pimpl && !MTPolicy::decrementCount(m_pimpl->m_ref_count) )
+ boost::checked_delete(m_pimpl), m_pimpl = nullptr;
}
public:
@@ -219,6 +219,14 @@ int cow_wrapper_client::queryUnmodified() const
MTPolicy::incrementCount( m_pimpl->m_ref_count );
}
+ /** Move-construct and steal rSrc shared resource
+ */
+ explicit cow_wrapper( cow_wrapper&& rSrc ) :
+ m_pimpl( rSrc.m_pimpl )
+ {
+ rSrc.m_pimpl = nullptr;
+ }
+
~cow_wrapper() // nothrow, if ~T does not throw
{
release();
@@ -236,6 +244,18 @@ int cow_wrapper_client::queryUnmodified() const
return *this;
}
+ /// stealing rSrc's resource
+ cow_wrapper& operator=( cow_wrapper&& rSrc )
+ {
+ // self-movement guts ourself, see also 17.6.4.9
+ release();
+ m_pimpl = rSrc.m_pimpl;
+
+ rSrc.m_pimpl = nullptr;
+
+ return *this;
+ }
+
/// unshare with any other cow_wrapper instance
value_type& make_unique()
{