From: khizmax Date: Tue, 5 Apr 2016 20:35:56 +0000 (+0300) Subject: Fixed emplace() function X-Git-Tag: v2.2.0~291 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=50877a4b7aac0112aec3e33d15fd58948cd2d7ee;p=libcds.git Fixed emplace() function --- diff --git a/cds/container/striped_map/std_list.h b/cds/container/striped_map/std_list.h index b4368383..10080dd1 100644 --- a/cds/container/striped_map/std_list.h +++ b/cds/container/striped_map/std_list.h @@ -194,10 +194,10 @@ namespace cds { namespace intrusive { namespace striped_set { template bool emplace( K&& key, Args&&... args ) { - iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() ); - if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) { - //value_type newItem( key ); - it = m_List.emplace( it, value_type( std::forward(key), std::move( mapped_type( std::forward(args)...) )) ); + value_type val( key_type( std::forward( key )), mapped_type( std::forward( args )... )); + iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate() ); + if ( it == m_List.end() || key_comparator()( val.first, it->first ) != 0 ) { + it = m_List.emplace( it, std::move( val )); # if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM) ++m_nSize;