diff options
author | Daniel Robertson <danlrobertson89@gmail.com> | 2015-08-27 17:55:55 -0400 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-08-29 22:47:38 +0000 |
commit | 311e77440f11dbe8e49d75b09a4ae0f850ce00c5 (patch) | |
tree | f93c323d2e102f6258eadbdd9b71b310970331f4 /include/o3tl | |
parent | 77a0897e6000990666d6f4dad54d549b0b7fda27 (diff) |
o3tl: add another unit test to cow_wrapper
Add unit tests to cow_wrapper for the move ctor and move assignment.
Change-Id: I82a5886ca7ae110985c7202125699cf95b6466d8
Reviewed-on: https://gerrit.libreoffice.org/18108
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'include/o3tl')
-rw-r--r-- | include/o3tl/cow_wrapper.hxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/include/o3tl/cow_wrapper.hxx b/include/o3tl/cow_wrapper.hxx index 3f117a2b395b..da822b2c88b8 100644 --- a/include/o3tl/cow_wrapper.hxx +++ b/include/o3tl/cow_wrapper.hxx @@ -113,9 +113,11 @@ class cow_wrapper_client public: cow_wrapper_client(); cow_wrapper_client( const cow_wrapper_client& ); + cow_wrapper_client( cow_wrapper_client&& ); ~cow_wrapper_client(); cow_wrapper_client& operator=( const cow_wrapper_client& ); + cow_wrapper_client& operator=( cow_wrapper_client&& ); void modify( int nVal ); int queryUnmodified() const; @@ -144,6 +146,10 @@ cow_wrapper_client::cow_wrapper_client( const cow_wrapper_client& rSrc ) : maImpl( rSrc.maImpl ) { } +cow_wrapper_client::cow_wrapper_client( cow_wrapper_client& rSrc ) : + maImpl( std::move( rSrc.maImpl ) ) +{ +} cow_wrapper_client::~cow_wrapper_client() { } @@ -152,6 +158,11 @@ cow_wrapper_client& cow_wrapper_client::operator=( const cow_wrapper_client& rSr maImpl = rSrc.maImpl; return *this; } +cow_wrapper_client& cow_wrapper_client::operator=( cow_wrapper_client&& rSrc ) +{ + maImpl = std::move( rSrc.maImpl ); + return *this; +} void cow_wrapper_client::modify( int nVal ) { maImpl->setValue( nVal ); @@ -272,13 +283,13 @@ int cow_wrapper_client::queryUnmodified() const /// true, if not shared with any other cow_wrapper instance bool is_unique() const // nothrow { - return m_pimpl->m_ref_count == 1; + return m_pimpl ? m_pimpl->m_ref_count == 1 : true; } /// return number of shared instances (1 for unique object) typename MTPolicy::ref_count_t use_count() const // nothrow { - return m_pimpl->m_ref_count; + return m_pimpl ? m_pimpl->m_ref_count : 0; } void swap(cow_wrapper& r) // never throws |