From: khizmax Date: Sat, 26 Mar 2016 14:33:37 +0000 (+0300) Subject: Fixed container::StripedSet::emplace() bug X-Git-Tag: v2.2.0~319 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d5a609092b48d81c8a751f4df55b48aa3cfa80bb;p=libcds.git Fixed container::StripedSet::emplace() bug Minor fixes --- diff --git a/cds/container/striped_set.h b/cds/container/striped_set.h index c859da6d..e4f4ec78 100644 --- a/cds/container/striped_set.h +++ b/cds/container/striped_set.h @@ -624,13 +624,14 @@ namespace cds { namespace container { { bool bOk; bool bResize; - size_t nHash = base_class::hashing( value_type( std::forward(args)...)); + value_type val( std::forward( args )... ); + size_t nHash = base_class::hashing( val ); bucket_type * pBucket; { scoped_cell_lock sl( base_class::m_MutexPolicy, nHash ); pBucket = base_class::bucket( nHash ); - bOk = pBucket->emplace( std::forward(args)...); + bOk = pBucket->emplace( std::move( val )); bResize = bOk && base_class::m_ResizingPolicy( ++base_class::m_ItemCounter, *this, *pBucket ); } @@ -667,7 +668,7 @@ namespace cds { namespace container { std::pair update( Q const& val, Func func, bool bAllowInsert = true ) { std::pair result; - bool bResize; + bool bResize = false; size_t nHash = base_class::hashing( val ); bucket_type * pBucket; { @@ -675,7 +676,8 @@ namespace cds { namespace container { pBucket = base_class::bucket( nHash ); result = pBucket->update( val, func, bAllowInsert ); - bResize = result.first && result.second && base_class::m_ResizingPolicy( ++base_class::m_ItemCounter, *this, *pBucket ); + if ( result.first && result.second ) + bResize = base_class::m_ResizingPolicy( ++base_class::m_ItemCounter, *this, *pBucket ); } if ( bResize ) diff --git a/cds/container/striped_set/adapter.h b/cds/container/striped_set/adapter.h index f6738022..bbb1be14 100644 --- a/cds/container/striped_set/adapter.h +++ b/cds/container/striped_set/adapter.h @@ -328,7 +328,7 @@ namespace cds { namespace container { return std::make_pair( true, res.second ); } else { - auto it = m_Set.find( val ); + auto it = m_Set.find( value_type( val )); if ( it == m_Set.end() ) return std::make_pair( false, false ); func( false, const_cast(*it), val );