From b0c34f01f53c50aac53bbffc5582a64d983337d6 Mon Sep 17 00:00:00 2001 From: khizmax Date: Thu, 7 Apr 2016 00:37:20 +0300 Subject: [PATCH] Fixed explicit ctor incompatibility --- cds/container/striped_map.h | 8 ++++---- cds/container/striped_map/boost_flat_map.h | 4 ---- cds/container/striped_map/boost_list.h | 12 ++++++------ cds/container/striped_map/boost_slist.h | 8 +++----- cds/container/striped_map/std_hash_map.h | 16 ++++++++-------- cds/container/striped_map/std_list.h | 6 ++---- cds/container/striped_map/std_map.h | 16 ++++++++-------- cds/container/striped_set/adapter.h | 12 ++++++------ 8 files changed, 37 insertions(+), 45 deletions(-) diff --git a/cds/container/striped_map.h b/cds/container/striped_map.h index 88ca30dd..40b32ae3 100644 --- a/cds/container/striped_map.h +++ b/cds/container/striped_map.h @@ -241,7 +241,7 @@ namespace cds { namespace container { #include #include typedef cds::container::StripedMap< - boost::container::map< Key, T, std::pair< const Key, T> > + boost::container::map< Key, T, std::less > > striped_map; \endcode @@ -256,7 +256,7 @@ namespace cds { namespace container { #include typedef cds::container::StripedMap< boost::container::flat_map< Key, T, - std::less< std::pair< const Key, T> > + std::less< std::less > > > striped_map; \endcode @@ -286,7 +286,7 @@ namespace cds { namespace container { There are two possibility: - either your \p MyBestContainer class has native support of bucket's interface; in this case, you can use default striped_set::adapt metafunction; - - or your \p MyBestContainer class does not support bucket's interface, which means, that you should develop a specialization + - or your \p MyBestContainer class does not support bucket's interface; it means you should develop a specialization cds::container::striped_set::adapt metafunction providing necessary interface. The striped_set::adapt< Container, Options... > metafunction has two template argument: @@ -295,7 +295,7 @@ namespace cds { namespace container { any option from \p Options for its internal use. For example, a \p compare option can be passed to \p adapt metafunction via \p Options argument of \p %StripedMap declaration. - See striped_set::adapt metafunction for the description of interface that the bucket container must provide + See \p striped_set::adapt metafunction for the description of interface that the bucket container must provide to be \p %StripedMap compatible. Copy policy diff --git a/cds/container/striped_map/boost_flat_map.h b/cds/container/striped_map/boost_flat_map.h index 6921db98..72bf0641 100644 --- a/cds/container/striped_map/boost_flat_map.h +++ b/cds/container/striped_map/boost_flat_map.h @@ -39,10 +39,6 @@ #include #include -//#if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION >= 1700 -//# error "boost::container::flat_map is not compatible with MS VC++ 11" -//#endif - //@cond namespace cds { namespace container { diff --git a/cds/container/striped_map/boost_list.h b/cds/container/striped_map/boost_list.h index 94125ed7..f39e4a88 100644 --- a/cds/container/striped_map/boost_list.h +++ b/cds/container/striped_map/boost_list.h @@ -167,7 +167,7 @@ namespace cds { namespace intrusive { namespace striped_set { 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.insert( it, value_type( key, mapped_type()) ); + it = m_List.insert( it, value_type( key_type( key ), mapped_type()) ); f( *it ); return true; @@ -180,9 +180,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 ) { - m_List.emplace( it, 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 ) { + m_List.emplace( it, std::move( val )); return true; } return false; @@ -197,8 +198,7 @@ namespace cds { namespace intrusive { namespace striped_set { if ( !bAllowInsert ) return std::make_pair( false, false ); - value_type newItem( key, mapped_type() ); - it = m_List.insert( it, newItem ); + it = m_List.insert( it, value_type( key_type( key ), mapped_type() )); func( true, *it ); return std::make_pair( true, true ); diff --git a/cds/container/striped_map/boost_slist.h b/cds/container/striped_map/boost_slist.h index c154b951..a5e7b00d 100644 --- a/cds/container/striped_map/boost_slist.h +++ b/cds/container/striped_map/boost_slist.h @@ -178,8 +178,7 @@ namespace cds { namespace intrusive { namespace striped_set { { std::pair< iterator, bool > pos = find_prev_item( key ); if ( !pos.second ) { - value_type newItem( key, mapped_type() ); - pos.first = m_List.insert_after( pos.first, newItem ); + pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() )); f( *pos.first ); return true; } @@ -193,7 +192,7 @@ namespace cds { namespace intrusive { namespace striped_set { { std::pair< iterator, bool > pos = find_prev_item( key ); if ( !pos.second ) { - m_List.emplace_after( pos.first, std::forward(key), std::move( mapped_type( std::forward(args)... ))); + m_List.emplace_after( pos.first, key_type( std::forward( key )), mapped_type( std::forward( args )... )); return true; } return false; @@ -208,8 +207,7 @@ namespace cds { namespace intrusive { namespace striped_set { if ( !bAllowInsert ) return std::make_pair( false, false ); - value_type newItem( key, mapped_type() ); - pos.first = m_List.insert_after( pos.first, newItem ); + pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() )); func( true, *pos.first ); return std::make_pair( true, true ); } diff --git a/cds/container/striped_map/std_hash_map.h b/cds/container/striped_map/std_hash_map.h index da588204..4cfe659a 100644 --- a/cds/container/striped_map/std_hash_map.h +++ b/cds/container/striped_map/std_hash_map.h @@ -132,7 +132,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool insert( const Q& key, Func f ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() )); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() )); if ( res.second ) f( const_cast(*res.first) ); return res.second; @@ -141,7 +141,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool emplace( Q&& key, Args&&... args ) { - std::pair res = m_Map.emplace( std::forward(key), std::move( mapped_type(std::forward(args)...)) ); + std::pair res = m_Map.emplace( key_type( std::forward( key )), mapped_type( std::forward( args )...)); return res.second; } @@ -149,12 +149,12 @@ namespace cds { namespace intrusive { namespace striped_set { std::pair update( const Q& key, Func func, bool bAllowInsert ) { if ( bAllowInsert ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() ) ); func( res.second, const_cast(*res.first)); return std::make_pair( true, res.second ); } else { - auto it = m_Map.find(key_type( key )); + auto it = m_Map.find( key_type( key )); if ( it == end() ) return std::make_pair( false, false ); func( false, *it ); @@ -165,7 +165,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool erase( const Q& key, Func f ) { - iterator it = m_Map.find( key_type(key) ); + iterator it = m_Map.find( key_type( key )); if ( it == m_Map.end() ) return false; f( const_cast(*it) ); @@ -174,12 +174,12 @@ namespace cds { namespace intrusive { namespace striped_set { } template - bool find( Q& val, Func f ) + bool find( Q& key, Func f ) { - iterator it = m_Map.find( key_type(val) ); + iterator it = m_Map.find( key_type( key )); if ( it == m_Map.end() ) return false; - f( const_cast(*it), val ); + f( const_cast(*it), key ); return true; } diff --git a/cds/container/striped_map/std_list.h b/cds/container/striped_map/std_list.h index 10080dd1..cc19f06d 100644 --- a/cds/container/striped_map/std_list.h +++ b/cds/container/striped_map/std_list.h @@ -177,8 +177,7 @@ namespace cds { namespace intrusive { namespace striped_set { { 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.insert( it, value_type( key, mapped_type()) ); + it = m_List.insert( it, value_type( key_type( key ), mapped_type()) ); f( *it ); # if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM) @@ -216,8 +215,7 @@ namespace cds { namespace intrusive { namespace striped_set { if ( !bAllowInsert ) return std::make_pair( false, false ); - value_type newItem( key, mapped_type() ); - it = m_List.insert( it, newItem ); + it = m_List.insert( it, value_type( key_type( key ), mapped_type() )); func( true, *it ); # if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM) ++m_nSize; diff --git a/cds/container/striped_map/std_map.h b/cds/container/striped_map/std_map.h index 3c0b37d9..76da98bb 100644 --- a/cds/container/striped_map/std_map.h +++ b/cds/container/striped_map/std_map.h @@ -132,7 +132,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool insert( const Q& key, Func f ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() ) ); if ( res.second ) f( *res.first ); return res.second; @@ -141,7 +141,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool emplace( Q&& key, Args&&... args ) { - std::pair res = m_Map.emplace( std::forward(key), std::move(mapped_type( std::forward(args)...))); + std::pair res = m_Map.emplace( key_type( std::forward( key )), mapped_type( std::forward( args )...)); return res.second; } @@ -149,12 +149,12 @@ namespace cds { namespace intrusive { namespace striped_set { std::pair update( const Q& key, Func func, bool bAllowInsert ) { if ( bAllowInsert ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() )); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() )); func( res.second, *res.first ); return std::make_pair( true, res.second ); } else { - auto it = m_Map.find(key_type( key )); + auto it = m_Map.find( key_type( key )); if ( it == end() ) return std::make_pair( false, false ); func( false, *it ); @@ -165,7 +165,7 @@ namespace cds { namespace intrusive { namespace striped_set { template bool erase( const Q& key, Func f ) { - iterator it = m_Map.find( key_type(key) ); + iterator it = m_Map.find( key_type( key )); if ( it == m_Map.end() ) return false; f( *it ); @@ -174,12 +174,12 @@ namespace cds { namespace intrusive { namespace striped_set { } template - bool find( Q& val, Func f ) + bool find( Q& key, Func f ) { - iterator it = m_Map.find( key_type(val) ); + iterator it = m_Map.find( key_type( key )); if ( it == m_Map.end() ) return false; - f( *it, val ); + f( *it, key ); return true; } diff --git a/cds/container/striped_set/adapter.h b/cds/container/striped_set/adapter.h index bbb1be14..3f0df642 100644 --- a/cds/container/striped_set/adapter.h +++ b/cds/container/striped_set/adapter.h @@ -452,7 +452,7 @@ namespace cds { namespace container { template bool insert( const Q& key, Func f ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() ) ); if ( res.second ) f( *res.first ); return res.second; @@ -461,7 +461,7 @@ namespace cds { namespace container { template bool emplace( Q&& key, Args&&... args ) { - std::pair res = m_Map.emplace( std::forward(key), std::move( mapped_type( std::forward(args)...))); + std::pair res = m_Map.emplace( key_type( std::forward( key )), mapped_type( std::forward( args )...)); return res.second; } @@ -469,12 +469,12 @@ namespace cds { namespace container { std::pair update( const Q& key, Func func, bool bAllowInsert ) { if ( bAllowInsert ) { - std::pair res = m_Map.insert( value_type( key, mapped_type() )); + std::pair res = m_Map.insert( value_type( key_type( key ), mapped_type() )); func( res.second, *res.first ); return std::make_pair( true, res.second ); } else { - auto it = m_Map.find(key_type( key )); + auto it = m_Map.find( key_type( key )); if ( it == end() ) return std::make_pair( false, false ); func( false, *it ); @@ -485,7 +485,7 @@ namespace cds { namespace container { template bool erase( const Q& key, Func f ) { - iterator it = m_Map.find( key_type(key) ); + iterator it = m_Map.find( key_type( key )); if ( it == m_Map.end() ) return false; f( *it ); @@ -496,7 +496,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) { - iterator it = m_Map.find( key_type(val) ); + iterator it = m_Map.find( key_type( val )); if ( it == m_Map.end() ) return false; f( *it, val ); -- 2.34.1