From 01266e5b6323ab12023783a42155349d7ee279da Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 23 Jan 2015 12:54:44 +0300 Subject: [PATCH] Removed MSVC 2008 artefacts --- cds/container/striped_map/std_hash_map.h | 179 ++++++++++++++++- cds/container/striped_map/std_hash_map_std.h | 184 ------------------ cds/container/striped_map/std_hash_map_vc.h | 178 ----------------- cds/container/striped_set/std_hash_set.h | 162 ++++++++++++++- cds/container/striped_set/std_hash_set_std.h | 167 ---------------- cds/container/striped_set/std_hash_set_vc.h | 162 --------------- projects/Win/vc12/cds.vcxproj | 4 - projects/Win/vc12/cds.vcxproj.filters | 12 -- .../Win/vc12/hdr-test-striped-set.vcxproj | 2 - .../vc12/hdr-test-striped-set.vcxproj.filters | 6 - .../map/hdr_refinable_hashmap_hashmap_std.cpp | 4 - .../map/hdr_striped_hashmap_hashmap_std.cpp | 4 - .../set/hdr_refinable_hashset_hashset_std.cpp | 3 - .../set/hdr_refinable_hashset_hashset_vc.cpp | 156 --------------- .../set/hdr_striped_hashset_hashset_std.cpp | 3 - .../set/hdr_striped_hashset_hashset_vc.cpp | 149 -------------- 16 files changed, 329 insertions(+), 1046 deletions(-) delete mode 100644 cds/container/striped_map/std_hash_map_std.h delete mode 100644 cds/container/striped_map/std_hash_map_vc.h delete mode 100644 cds/container/striped_set/std_hash_set_std.h delete mode 100644 cds/container/striped_set/std_hash_set_vc.h delete mode 100644 tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp delete mode 100644 tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp diff --git a/cds/container/striped_map/std_hash_map.h b/cds/container/striped_map/std_hash_map.h index 95df3279..6904505d 100644 --- a/cds/container/striped_map/std_hash_map.h +++ b/cds/container/striped_map/std_hash_map.h @@ -4,10 +4,177 @@ #define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008 -# include -#else -# include -#endif +#include -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H +//@cond +namespace cds { namespace container { + namespace striped_set { + + // Copy policy for map + template + struct copy_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > + { + typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; + typedef typename map_type::value_type pair_type; + typedef typename map_type::iterator iterator; + + void operator()( map_type& map, iterator itWhat ) + { + map.insert( *itWhat ); + } + }; + + // Swap policy for map + template + struct swap_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > + { + typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; + typedef typename map_type::value_type pair_type; + typedef typename map_type::iterator iterator; + + void operator()( map_type& map, iterator itWhat ) + { + pair_type pair( itWhat->first, typename pair_type::second_type() ); + std::pair res = map.insert( pair ); + assert( res.second ); + std::swap( res.first->second, itWhat->second ); + } + }; + + // Move policy for map + template + struct move_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > + { + typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; + typedef typename map_type::value_type pair_type; + typedef typename map_type::iterator iterator; + + void operator()( map_type& map, iterator itWhat ) + { + map.insert( std::move( *itWhat ) ); + } + }; + } // namespace striped_set +}} // namespace cds::container + +namespace cds { namespace intrusive { namespace striped_set { + + /// std::unordered_map adapter for hash map bucket + template + class adapt< std::unordered_map< Key, T, Hash, Pred, Alloc>, Options... > + { + public: + typedef std::unordered_map< Key, T, Hash, Pred, Alloc> container_type ; ///< underlying container type + + private: + /// Adapted container type + class adapted_container: public cds::container::striped_set::adapted_container + { + public: + typedef typename container_type::value_type value_type ; ///< value type stored in the container + typedef typename container_type::key_type key_type; + typedef typename container_type::mapped_type mapped_type; + typedef typename container_type::iterator iterator ; ///< container iterator + typedef typename container_type::const_iterator const_iterator ; ///< container const iterator + + static bool const has_find_with = false; + static bool const has_erase_with = false; + + private: + //@cond + typedef typename cds::opt::select< + typename cds::opt::value< + typename cds::opt::find_option< + cds::opt::copy_policy< cds::container::striped_set::move_item > + , Options... + >::type + >::copy_policy + , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy + , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy + , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy + >::type copy_item; + //@endcond + + private: + //@cond + container_type m_Map; + //@endcond + + public: + template + bool insert( const Q& key, Func f ) + { + std::pair res = m_Map.insert( value_type( key, mapped_type() )); + if ( res.second ) + f( const_cast(*res.first) ); + return res.second; + } + + template + bool emplace( Q&& key, Args&&... args ) + { + std::pair res = m_Map.emplace( std::forward(key), std::move( mapped_type(std::forward(args)...)) ); + return res.second; + } + + template + std::pair ensure( const Q& key, Func func ) + { + std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); + func( res.second, const_cast(*res.first)); + return std::make_pair( true, res.second ); + } + + template + bool erase( const Q& key, Func f ) + { + iterator it = m_Map.find( key_type(key) ); + if ( it == m_Map.end() ) + return false; + f( const_cast(*it) ); + m_Map.erase( it ); + return true; + } + + template + bool find( Q& val, Func f ) + { + iterator it = m_Map.find( key_type(val) ); + if ( it == m_Map.end() ) + return false; + f( const_cast(*it), val ); + return true; + } + + void clear() + { + m_Map.clear(); + } + + iterator begin() { return m_Map.begin(); } + const_iterator begin() const { return m_Map.begin(); } + iterator end() { return m_Map.end(); } + const_iterator end() const { return m_Map.end(); } + + void move_item( adapted_container& /*from*/, iterator itWhat ) + { + assert( m_Map.find( itWhat->first ) == m_Map.end() ); + copy_item()( m_Map, itWhat ); + } + + size_t size() const + { + return m_Map.size(); + } + }; + + public: + typedef adapted_container type ; ///< Result of \p adapt metafunction + + }; +}}} // namespace cds::intrusive::striped_set + + +//@endcond + +#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H diff --git a/cds/container/striped_map/std_hash_map_std.h b/cds/container/striped_map/std_hash_map_std.h deleted file mode 100644 index 4fc9e3ff..00000000 --- a/cds/container/striped_map/std_hash_map_std.h +++ /dev/null @@ -1,184 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H -#define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H - -#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H -# error must be included instead of header -#endif - -#include -#include - -//@cond -namespace cds { namespace container { - namespace striped_set { - - // Copy policy for map - template - struct copy_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > - { - typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - map.insert( *itWhat ); - } - }; - - // Swap policy for map - template - struct swap_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > - { - typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - pair_type pair( itWhat->first, typename pair_type::second_type() ); - std::pair res = map.insert( pair ); - assert( res.second ); - std::swap( res.first->second, itWhat->second ); - } - }; - - // Move policy for map - template - struct move_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > > - { - typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - map.insert( std::move( *itWhat ) ); - } - }; - } // namespace striped_set -}} // namespace cds::container - -namespace cds { namespace intrusive { namespace striped_set { - - /// std::unordered_map adapter for hash map bucket - template - class adapt< std::unordered_map< Key, T, Hash, Pred, Alloc>, Options... > - { - public: - typedef std::unordered_map< Key, T, Hash, Pred, Alloc> container_type ; ///< underlying container type - - private: - /// Adapted container type - class adapted_container: public cds::container::striped_set::adapted_container - { - public: - typedef typename container_type::value_type value_type ; ///< value type stored in the container - typedef typename container_type::key_type key_type; - typedef typename container_type::mapped_type mapped_type; - typedef typename container_type::iterator iterator ; ///< container iterator - typedef typename container_type::const_iterator const_iterator ; ///< container const iterator - - static bool const has_find_with = false; - static bool const has_erase_with = false; - - private: - //@cond - typedef typename cds::opt::select< - typename cds::opt::value< - typename cds::opt::find_option< - cds::opt::copy_policy< cds::container::striped_set::move_item > - , Options... - >::type - >::copy_policy - , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy - , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy - , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy - >::type copy_item; - //@endcond - - private: - //@cond - container_type m_Map; - //@endcond - - public: - template - bool insert( const Q& key, Func f ) - { - std::pair res = m_Map.insert( value_type( key, mapped_type() )); - if ( res.second ) - f( const_cast(*res.first) ); - return res.second; - } - - template - bool emplace( Q&& key, Args&&... args ) - { - std::pair res = m_Map.emplace( std::forward(key), std::move( mapped_type(std::forward(args)...)) ); - return res.second; - } - - template - std::pair ensure( const Q& key, Func func ) - { - std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); - func( res.second, const_cast(*res.first)); - return std::make_pair( true, res.second ); - } - - template - bool erase( const Q& key, Func f ) - { - iterator it = m_Map.find( key_type(key) ); - if ( it == m_Map.end() ) - return false; - f( const_cast(*it) ); - m_Map.erase( it ); - return true; - } - - template - bool find( Q& val, Func f ) - { - iterator it = m_Map.find( key_type(val) ); - if ( it == m_Map.end() ) - return false; - f( const_cast(*it), val ); - return true; - } - - void clear() - { - m_Map.clear(); - } - - iterator begin() { return m_Map.begin(); } - const_iterator begin() const { return m_Map.begin(); } - iterator end() { return m_Map.end(); } - const_iterator end() const { return m_Map.end(); } - - void move_item( adapted_container& /*from*/, iterator itWhat ) - { - assert( m_Map.find( itWhat->first ) == m_Map.end() ); - copy_item()( m_Map, itWhat ); - } - - size_t size() const - { - return m_Map.size(); - } - }; - - public: - typedef adapted_container type ; ///< Result of \p adapt metafunction - - }; -}}} // namespace cds::intrusive::striped_set - - -//@endcond - -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H diff --git a/cds/container/striped_map/std_hash_map_vc.h b/cds/container/striped_map/std_hash_map_vc.h deleted file mode 100644 index 91e7a488..00000000 --- a/cds/container/striped_map/std_hash_map_vc.h +++ /dev/null @@ -1,178 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H -#define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H - -#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H -# error must be included instead of header -#endif - -#include -#include - -//@cond -namespace cds { namespace container { - namespace striped_set { - - // Copy policy for map - template - struct copy_item_policy< stdext::hash_map< Key, T, Traits, Alloc > > - { - typedef stdext::hash_map< Key, T, Traits, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - std::pair< typename map_type::iterator, bool> res = map.insert( *itWhat ); - assert( res.second ) ; // succesful insert - } - }; - - // Swap policy for map - template - struct swap_item_policy< stdext::hash_map< Key, T, Traits, Alloc > > - { - typedef stdext::hash_map< Key, T, Traits, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - pair_type newVal( itWhat->first, typename pair_type::second_type() ); - std::pair< typename map_type::iterator, bool> res = map.insert( newVal ); - assert( res.second ) ; // succesful insert - std::swap( res.first->second, itWhat->second ); - } - }; - - // Move policy for map - template - struct move_item_policy< stdext::hash_map< Key, T, Traits, Alloc > > - { - typedef stdext::hash_map< Key, T, Traits, Alloc > map_type; - typedef typename map_type::value_type pair_type; - typedef typename map_type::iterator iterator; - - void operator()( map_type& map, iterator itWhat ) - { - map.insert( std::move( *itWhat ) ); - } - }; - } // namespace striped_set -}} // namespace cds::container - -namespace cds { namespace intrusive { namespace striped_set { - - /// stdext::hash_map adapter for hash map bucket - template - class adapt< stdext::hash_map< Key, T, Traits, Alloc>, Options... > - { - public: - typedef stdext::hash_map< Key, T, Traits, Alloc> container_type ; ///< underlying container type - - private: - /// Adapted container type - class adapted_container: public cds::container::striped_set::adapted_container - { - public: - typedef typename container_type::value_type value_type ; ///< value type stored in the container - typedef typename container_type::key_type key_type; - typedef typename container_type::mapped_type mapped_type; - typedef typename container_type::iterator iterator ; ///< container iterator - typedef typename container_type::const_iterator const_iterator ; ///< container const iterator - - static bool const has_find_with = false; - static bool const has_erase_with = false; - - private: - //@cond - typedef typename cds::opt::select< - typename cds::opt::value< - typename cds::opt::find_option< - cds::opt::copy_policy< cds::container::striped_set::move_item > - , Options... - >::type - >::copy_policy - , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy - , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy - , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy - >::type copy_item; - //@endcond - - private: - //@cond - container_type m_Map; - //@endcond - - public: - template - bool insert( const Q& key, Func f ) - { - std::pair res = m_Map.insert( value_type( key, mapped_type() ) ); - if ( res.second ) - f( *res.first ); - return res.second; - } - - template - std::pair ensure( const Q& val, Func func ) - { - std::pair res = m_Map.insert( value_type( val, mapped_type() )); - func( res.second, *res.first ); - return std::make_pair( true, res.second ); - } - - template - bool erase( const Q& key, Func f ) - { - iterator it = m_Map.find( key_type(key) ); - if ( it == m_Map.end() ) - return false; - f( *it ); - m_Map.erase( it ); - return true; - } - - template - bool find( Q& val, Func f ) - { - iterator it = m_Map.find( key_type(val) ); - if ( it == m_Map.end() ) - return false; - f( *it, val ); - return true; - } - - void clear() - { - m_Map.clear(); - } - - iterator begin() { return m_Map.begin(); } - const_iterator begin() const { return m_Map.begin(); } - iterator end() { return m_Map.end(); } - const_iterator end() const { return m_Map.end(); } - - void move_item( adapted_container& /*from*/, iterator itWhat ) - { - assert( m_Map.find( itWhat->first ) == m_Map.end() ); - copy_item()( m_Map, itWhat ); - } - - size_t size() const - { - return m_Map.size(); - } - }; - - public: - typedef adapted_container type ; ///< Result of \p adapt metafunction - - }; -}}} // namespace cds::intrusive::striped_set - - -//@endcond - -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H diff --git a/cds/container/striped_set/std_hash_set.h b/cds/container/striped_set/std_hash_set.h index 0fa59b4d..18362470 100644 --- a/cds/container/striped_set/std_hash_set.h +++ b/cds/container/striped_set/std_hash_set.h @@ -4,10 +4,160 @@ #define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008 -# include -#else -# include -#endif +#include -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H +//@cond +namespace cds { namespace container { + namespace striped_set { + + // Copy policy for std::unordered_set + template + struct copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > + { + typedef std::unordered_set< T, Hash, Pred, Alloc > set_type; + typedef typename set_type::iterator iterator; + + void operator()( set_type& set, iterator itWhat ) + { + set.insert( *itWhat ); + } + }; + + template + struct swap_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >: public copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > + {}; + + // Move policy for std::unordered_set + template + struct move_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > + { + typedef std::unordered_set< T, Hash, Pred, Alloc > set_type; + typedef typename set_type::iterator iterator; + + void operator()( set_type& set, iterator itWhat ) + { + set.insert( std::move( *itWhat ) ); + } + }; + + } // namespace striped_set +}} // namespace cds::container + +namespace cds { namespace intrusive { namespace striped_set { + /// std::unordered_set adapter for hash set bucket + template + class adapt< std::unordered_set, Options... > + { + public: + typedef std::unordered_set container_type ; ///< underlying container type + + private: + /// Adapted container type + class adapted_container: public cds::container::striped_set::adapted_container + { + public: + typedef typename container_type::value_type value_type ; ///< value type stored in the container + typedef typename container_type::iterator iterator ; ///< container iterator + typedef typename container_type::const_iterator const_iterator ; ///< container const iterator + + static bool const has_find_with = false; + static bool const has_erase_with = false; + + private: + //@cond + typedef typename cds::opt::select< + typename cds::opt::value< + typename cds::opt::find_option< + cds::opt::copy_policy< cds::container::striped_set::move_item > + , Options... + >::type + >::copy_policy + , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy + , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy // not defined + , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy + >::type copy_item; + //@endcond + + private: + //@cond + container_type m_Set; + //@endcond + + public: + template + bool insert( const Q& val, Func f ) + { + std::pair res = m_Set.insert( value_type(val) ); + if ( res.second ) + f( const_cast(*res.first) ); + return res.second; + } + + template + bool emplace( Args&&... args ) + { + std::pair res = m_Set.emplace( std::forward(args)... ); + return res.second; + } + + template + std::pair ensure( const Q& val, Func func ) + { + std::pair res = m_Set.insert( value_type(val) ); + func( res.second, const_cast(*res.first), val ); + return std::make_pair( true, res.second ); + } + + template + bool erase( const Q& key, Func f ) + { + const_iterator it = m_Set.find( value_type(key) ); + if ( it == m_Set.end() ) + return false; + f( const_cast(*it) ); + m_Set.erase( it ); + return true; + } + + template + bool find( Q& val, Func f ) + { + iterator it = m_Set.find( value_type(val) ); + if ( it == m_Set.end() ) + return false; + f( const_cast(*it), val ); + return true; + } + + /// Clears the container + void clear() + { + m_Set.clear(); + } + + iterator begin() { return m_Set.begin(); } + const_iterator begin() const { return m_Set.begin(); } + iterator end() { return m_Set.end(); } + const_iterator end() const { return m_Set.end(); } + + void move_item( adapted_container& /*from*/, iterator itWhat ) + { + assert( m_Set.find( *itWhat ) == m_Set.end() ); + copy_item()( m_Set, itWhat ); + } + + size_t size() const + { + return m_Set.size(); + } + }; + + public: + typedef adapted_container type ; ///< Result of \p adapt metafunction + }; +}}} // namespace cds::intrusive::striped_set + + +//@endcond + +#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H diff --git a/cds/container/striped_set/std_hash_set_std.h b/cds/container/striped_set/std_hash_set_std.h deleted file mode 100644 index fdbcbcd1..00000000 --- a/cds/container/striped_set/std_hash_set_std.h +++ /dev/null @@ -1,167 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H -#define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H - -#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H -# error must be included instead of header -#endif - -#include -#include - -//@cond -namespace cds { namespace container { - namespace striped_set { - - // Copy policy for std::unordered_set - template - struct copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > - { - typedef std::unordered_set< T, Hash, Pred, Alloc > set_type; - typedef typename set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( *itWhat ); - } - }; - - template - struct swap_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >: public copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > - {}; - - // Move policy for std::unordered_set - template - struct move_item_policy< std::unordered_set< T, Hash, Pred, Alloc > > - { - typedef std::unordered_set< T, Hash, Pred, Alloc > set_type; - typedef typename set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( std::move( *itWhat ) ); - } - }; - - } // namespace striped_set -}} // namespace cds::container - -namespace cds { namespace intrusive { namespace striped_set { - /// std::unordered_set adapter for hash set bucket - template - class adapt< std::unordered_set, Options... > - { - public: - typedef std::unordered_set container_type ; ///< underlying container type - - private: - /// Adapted container type - class adapted_container: public cds::container::striped_set::adapted_container - { - public: - typedef typename container_type::value_type value_type ; ///< value type stored in the container - typedef typename container_type::iterator iterator ; ///< container iterator - typedef typename container_type::const_iterator const_iterator ; ///< container const iterator - - static bool const has_find_with = false; - static bool const has_erase_with = false; - - private: - //@cond - typedef typename cds::opt::select< - typename cds::opt::value< - typename cds::opt::find_option< - cds::opt::copy_policy< cds::container::striped_set::move_item > - , Options... - >::type - >::copy_policy - , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy - , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy // not defined - , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy - >::type copy_item; - //@endcond - - private: - //@cond - container_type m_Set; - //@endcond - - public: - template - bool insert( const Q& val, Func f ) - { - std::pair res = m_Set.insert( value_type(val) ); - if ( res.second ) - f( const_cast(*res.first) ); - return res.second; - } - - template - bool emplace( Args&&... args ) - { - std::pair res = m_Set.emplace( std::forward(args)... ); - return res.second; - } - - template - std::pair ensure( const Q& val, Func func ) - { - std::pair res = m_Set.insert( value_type(val) ); - func( res.second, const_cast(*res.first), val ); - return std::make_pair( true, res.second ); - } - - template - bool erase( const Q& key, Func f ) - { - const_iterator it = m_Set.find( value_type(key) ); - if ( it == m_Set.end() ) - return false; - f( const_cast(*it) ); - m_Set.erase( it ); - return true; - } - - template - bool find( Q& val, Func f ) - { - iterator it = m_Set.find( value_type(val) ); - if ( it == m_Set.end() ) - return false; - f( const_cast(*it), val ); - return true; - } - - /// Clears the container - void clear() - { - m_Set.clear(); - } - - iterator begin() { return m_Set.begin(); } - const_iterator begin() const { return m_Set.begin(); } - iterator end() { return m_Set.end(); } - const_iterator end() const { return m_Set.end(); } - - void move_item( adapted_container& /*from*/, iterator itWhat ) - { - assert( m_Set.find( *itWhat ) == m_Set.end() ); - copy_item()( m_Set, itWhat ); - } - - size_t size() const - { - return m_Set.size(); - } - }; - - public: - typedef adapted_container type ; ///< Result of \p adapt metafunction - }; -}}} // namespace cds::intrusive::striped_set - - -//@endcond - -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H diff --git a/cds/container/striped_set/std_hash_set_vc.h b/cds/container/striped_set/std_hash_set_vc.h deleted file mode 100644 index 09fa87c6..00000000 --- a/cds/container/striped_set/std_hash_set_vc.h +++ /dev/null @@ -1,162 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H -#define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H - -#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H -# error must be included instead of header -#endif - -#include -#include - -//@cond -namespace cds { namespace container { - namespace striped_set { - - // Copy policy for stdext::hash_set - template - struct copy_item_policy< stdext::hash_set< T, Traits, Alloc > > - { - typedef stdext::hash_set< T, Traits, Alloc > set_type; - typedef typename set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( *itWhat ); - } - }; - - template - struct swap_item_policy< stdext::hash_set< T, Traits, Alloc > >: public copy_item_policy< stdext::hash_set< T, Traits, Alloc > > - {}; - - // Move policy for stdext::hash_set - template - struct move_item_policy< stdext::hash_set< T, Traits, Alloc > > - { - typedef stdext::hash_set< T, Traits, Alloc > set_type; - typedef typename set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( std::move( *itWhat ) ); - } - }; - - } // namespace striped_set -}} // namespace cds::container - -namespace cds { namespace intrusive { namespace striped_set { - - /// std::unordered_set adapter for hash set bucket - template - class adapt< stdext::hash_set, Options... > - { - public: - typedef stdext::hash_set container_type ; ///< underlying container type - - private: - /// Adapted container type - class adapted_container: public cds::container::striped_set::adapted_container - { - public: - typedef typename container_type::value_type value_type ; ///< value type stored in the container - typedef typename container_type::iterator iterator ; ///< container iterator - typedef typename container_type::const_iterator const_iterator ; ///< container const iterator - - static bool const has_find_with = false; - static bool const has_erase_with = false; - - private: - //@cond - typedef typename cds::opt::select< - typename cds::opt::value< - typename cds::opt::find_option< - cds::opt::copy_policy< cds::container::striped_set::move_item > - , Options... - >::type - >::copy_policy - , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy - , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy // not defined - , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy - >::type copy_item; - //@endcond - - private: - //@cond - container_type m_Set; - //@endcond - - public: - - template - bool insert( const Q& val, Func f ) - { - std::pair res = m_Set.insert( value_type(val) ); - if ( res.second ) - f( *res.first ); - return res.second; - } - - template - std::pair ensure( const Q& val, Func func ) - { - std::pair res = m_Set.insert( value_type(val) ); - func( res.second, *res.first, val ); - return std::make_pair( true, res.second ); - } - - template - bool erase( const Q& key, Func f ) - { - iterator it = m_Set.find( value_type(key) ); - if ( it == m_Set.end() ) - return false; - f( *it ); - m_Set.erase( it ); - return true; - } - - template - bool find( Q& val, Func f ) - { - iterator it = m_Set.find( value_type(val) ); - if ( it == m_Set.end() ) - return false; - f( *it, val ); - return true; - } - - /// Clears the container - void clear() - { - m_Set.clear(); - } - - iterator begin() { return m_Set.begin(); } - const_iterator begin() const { return m_Set.begin(); } - iterator end() { return m_Set.end(); } - const_iterator end() const { return m_Set.end(); } - - void move_item( adapted_container& /*from*/, iterator itWhat ) - { - assert( m_Set.find( *itWhat ) == m_Set.end() ); - copy_item()( m_Set, itWhat ); - } - - size_t size() const - { - return m_Set.size(); - } - }; - - public: - typedef adapted_container type ; ///< Result of \p adapt metafunction - - }; -}}} // namespace cds::intrusive::striped_set - -//@endcond - -#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H diff --git a/projects/Win/vc12/cds.vcxproj b/projects/Win/vc12/cds.vcxproj index 00a3ec82..59dcf331 100644 --- a/projects/Win/vc12/cds.vcxproj +++ b/projects/Win/vc12/cds.vcxproj @@ -713,8 +713,6 @@ - - @@ -727,8 +725,6 @@ - - diff --git a/projects/Win/vc12/cds.vcxproj.filters b/projects/Win/vc12/cds.vcxproj.filters index ce2c6f12..172436f4 100644 --- a/projects/Win/vc12/cds.vcxproj.filters +++ b/projects/Win/vc12/cds.vcxproj.filters @@ -716,12 +716,6 @@ Header Files\cds\container\striped_set - - Header Files\cds\container\striped_set - - - Header Files\cds\container\striped_set - Header Files\cds\container\striped_set @@ -749,12 +743,6 @@ Header Files\cds\container\striped_map - - Header Files\cds\container\striped_map - - - Header Files\cds\container\striped_map - Header Files\cds\container\striped_map diff --git a/projects/Win/vc12/hdr-test-striped-set.vcxproj b/projects/Win/vc12/hdr-test-striped-set.vcxproj index b2f0c87b..d62e3008 100644 --- a/projects/Win/vc12/hdr-test-striped-set.vcxproj +++ b/projects/Win/vc12/hdr-test-striped-set.vcxproj @@ -70,7 +70,6 @@ - @@ -82,7 +81,6 @@ - diff --git a/projects/Win/vc12/hdr-test-striped-set.vcxproj.filters b/projects/Win/vc12/hdr-test-striped-set.vcxproj.filters index 9e662789..80351d37 100644 --- a/projects/Win/vc12/hdr-test-striped-set.vcxproj.filters +++ b/projects/Win/vc12/hdr-test-striped-set.vcxproj.filters @@ -102,9 +102,6 @@ container\striped - - container\striped - container\striped @@ -138,9 +135,6 @@ container\striped - - container\striped - container\striped diff --git a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp index d3e06c03..0f8c79dc 100644 --- a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp +++ b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp @@ -5,8 +5,6 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) - namespace map { namespace { @@ -144,5 +142,3 @@ namespace map { } } // namespace map - -#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600) diff --git a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp index 95ca7221..ba31b020 100644 --- a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp +++ b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp @@ -5,8 +5,6 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) - namespace map { namespace { @@ -134,5 +132,3 @@ namespace map { } } // namespace map - -#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600) diff --git a/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp b/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp index 9d7d1ac1..cc921f19 100644 --- a/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp +++ b/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp @@ -5,8 +5,6 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) - namespace set { namespace { @@ -153,4 +151,3 @@ namespace set { } } // namespace set -#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600) diff --git a/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp b/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp deleted file mode 100644 index b12a079b..00000000 --- a/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp +++ /dev/null @@ -1,156 +0,0 @@ -//$$CDS-header$$ - -#include "set/hdr_striped_set.h" -#include -#include -#include - -#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 - -namespace stdext { - inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval) - { - return set::StripedSetHdrTest::hash_int()( _Keyval ); - } -} - -namespace set { - - namespace { - typedef stdext::hash_compare > hash_set_t; - - struct my_copy_policy { - typedef stdext::hash_set< StripedSetHdrTest::item, hash_set_t > set_type; - typedef set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( std::make_pair(itWhat->key(), itWhat->val()) ); - } - }; - - typedef stdext::hash_set set_t; - } - - void StripedSetHdrTest::Refinable_hashset() - { - CPPUNIT_MESSAGE( "cmp"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - ,co::mutex_policy< cc::striped_set::refinable<> > - > set_cmp; - test_striped< set_cmp >(); - - CPPUNIT_MESSAGE( "less"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::less< less > - > set_less; - test_striped< set_less >(); - - CPPUNIT_MESSAGE( "cmpmix"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::compare< cmp > - , co::less< less > - > set_cmpmix; - test_striped< set_cmpmix >(); - - // Spinlock as lock policy - CPPUNIT_MESSAGE( "spinlock"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable > - , co::hash< hash_int > - , co::less< less > - > set_spin; - test_striped< set_spin >(); - - // Resizing policy - CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)"); - { - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::load_factor_resizing<0> > - > set_less_resizing_lf; - set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024)); - test_striped_with(s); - } - - CPPUNIT_MESSAGE( "load_factor_resizing<256>"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - > set_less_resizing_lf16; - test_striped< set_less_resizing_lf16 >(); - - CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)"); - { - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> > - > set_less_resizing_sbt; - set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) ); - test_striped_with(s); - } - - CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> > - > set_less_resizing_sbt16; - test_striped< set_less_resizing_sbt16 >(); - - // Copy policy - CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::copy_item > - > set_copy_item; - test_striped< set_copy_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::swap_item > - > set_swap_item; - test_striped< set_swap_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::move_item > - > set_move_item; - test_striped< set_move_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item"); - typedef cc::StripedSet< set_t - ,co::mutex_policy< cc::striped_set::refinable<> > - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< my_copy_policy > - > set_special_copy_item; - test_striped< set_special_copy_item >(); - } -} // namespace set -#endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600 diff --git a/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp b/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp index 9f75a3c3..4d80b097 100644 --- a/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp +++ b/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp @@ -5,8 +5,6 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) - namespace set { namespace { @@ -146,4 +144,3 @@ namespace set { } } // namespace set -#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600) diff --git a/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp b/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp deleted file mode 100644 index 1c499ab9..00000000 --- a/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp +++ /dev/null @@ -1,149 +0,0 @@ -//$$CDS-header$$ - -#include "set/hdr_striped_set.h" -#include -#include -#include - -#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 - -namespace stdext { - inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval) - { - return set::StripedSetHdrTest::hash_int()( _Keyval ); - } -} - -namespace set { - - namespace { - typedef stdext::hash_compare > hash_set_t; - - struct my_copy_policy { - typedef stdext::hash_set< StripedSetHdrTest::item, hash_set_t > set_type; - typedef set_type::iterator iterator; - - void operator()( set_type& set, iterator itWhat ) - { - set.insert( std::make_pair(itWhat->key(), itWhat->val()) ); - } - }; - - typedef stdext::hash_set set_t; - } - - void StripedSetHdrTest::Striped_hashset() - { - CPPUNIT_MESSAGE( "cmp"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - ,co::mutex_policy< cc::striped_set::striping<> > - > set_cmp; - test_striped< set_cmp >(); - - CPPUNIT_MESSAGE( "less"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - ,co::mutex_policy< cc::striped_set::striping<> > - > set_less; - test_striped< set_less >(); - - CPPUNIT_MESSAGE( "cmpmix"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - , co::less< less > - ,co::mutex_policy< cc::striped_set::striping<> > - > set_cmpmix; - test_striped< set_cmpmix >(); - - // Spinlock as lock policy - CPPUNIT_MESSAGE( "spinlock"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > > - > set_spin; - test_striped< set_spin >(); - - // Resizing policy - CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)"); - { - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::load_factor_resizing<0> > - > set_less_resizing_lf; - set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>( 1024 )); - test_striped_with( s ); - } - - CPPUNIT_MESSAGE( "load_factor_resizing<256>"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - > set_less_resizing_lf16; - test_striped< set_less_resizing_lf16 >(); - - CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024"); - { - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> > - > set_less_resizing_sbt; - set_less_resizing_sbt s( 30, cc::striped_set::single_bucket_size_threshold<0>(1024)); - test_striped_with(s); - } - - CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::less< less > - , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> > - > set_less_resizing_sbt16; - test_striped< set_less_resizing_sbt16 >(); - - // Copy policy - CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::copy_item > - > set_copy_item; - test_striped< set_copy_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::swap_item > - > set_swap_item; - test_striped< set_swap_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< cc::striped_set::move_item > - > set_move_item; - test_striped< set_move_item >(); - - CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item"); - typedef cc::StripedSet< set_t - , co::hash< hash_int > - , co::compare< cmp > - , co::resizing_policy< cc::striped_set::load_factor_resizing<256> > - , co::copy_policy< my_copy_policy > - > set_special_copy_item; - test_striped< set_special_copy_item >(); - } - -} // namespace set -#endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600 -- 2.34.1