Remove hash_functor_selector.h, use only std::hash
authorkhizmax <libcds.dev@gmail.com>
Thu, 25 Sep 2014 18:55:53 +0000 (22:55 +0400)
committerkhizmax <libcds.dev@gmail.com>
Thu, 25 Sep 2014 18:55:53 +0000 (22:55 +0400)
Fix return value in intrusive MSPriorityQueue::pop()

cds/details/hash_functor_selector.h [deleted file]
cds/intrusive/mspriority_queue.h
cds/opt/hash.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
src/ptb_gc.cpp
tests/unit/map2/map_delodd.cpp
tests/unit/set2/set_delodd.cpp

diff --git a/cds/details/hash_functor_selector.h b/cds/details/hash_functor_selector.h
deleted file mode 100644 (file)
index c7a49d4..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H
-#define __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H
-
-//@cond
-
-#if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL
-#   include <functional>
-#elif CDS_COMPILER == CDS_COMPILER_GCC || CDS_COMPILER == CDS_COMPILER_CLANG
-    // GCC 4.3+
-#   include <functional>
-#else
-    // Default, use boost implementation
-#   include <boost/tr1/functional.hpp>
-#endif
-
-namespace cds { namespace details {
-
-#if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL
-#   if _MSC_VER >= 1600
-        // MSVC 2010 and above
-        using std::hash;
-#       define CDS_BEGIN_STD_HASH_NAMESPACE namespace std {
-#       define CDS_END_STD_HASH_NAMESPACE   }
-#       define CDS_STD_HASH_NAMESPACE std
-#   else
-        // MSVC 2008
-        using std::tr1::hash;
-#       define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { namespace tr1 {
-#       define CDS_END_STD_HASH_NAMESPACE   }}
-#       define CDS_STD_HASH_NAMESPACE std::tr1
-#   endif
-#elif CDS_COMPILER == CDS_COMPILER_GCC || CDS_COMPILER == CDS_COMPILER_CLANG
-    // GCC 4.3+
-    using std::hash;
-#   define CDS_BEGIN_STD_HASH_NAMESPACE namespace std {
-#   define CDS_END_STD_HASH_NAMESPACE   }
-#   define CDS_STD_HASH_NAMESPACE std
-#else
-    // Default, use boost implementation
-    using std::tr1::hash;
-#   define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { namespace tr1 {
-#   define CDS_END_STD_HASH_NAMESPACE   }}
-#   define CDS_STD_HASH_NAMESPACE std::tr1
-#endif
-
-}} // namespace cds::details
-//@endcond
-
-#endif // __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H
index d0a8d85..bd94dab 100644 (file)
@@ -286,7 +286,7 @@ namespace cds { namespace intrusive {
                 // the heap is empty
                 m_Lock.unlock();
                 m_Stat.onPopFailed();
-                return false;
+                return nullptr;
             }
             counter_type nBottom = m_ItemCounter.reversed_value();
             m_ItemCounter.dec();
index 18fe4bb..bd40719 100644 (file)
@@ -4,8 +4,8 @@
 #define __CDS_OPT_HASH_H
 
 #include <tuple>
+#include<functional>
 #include <cds/opt/options.h>
-#include <cds/details/hash_functor_selector.h>
 
 namespace cds { namespace opt {
 
@@ -36,10 +36,9 @@ namespace cds { namespace opt {
         /**
             The metafunction selects appropriate hash functor implementation.
             If \p Hash is not equal to opt::none, then result of metafunction is \p Hash.
-            Otherwise, the result is <tt> std::hash<Q> </tt> or <tt> boost::hash<Q> </tt>
-            depending of compiler you use.
+            Otherwise, the result is <tt> std::hash<Q> </tt>.
 
-            Note that default hash function like <tt> std::hash<Q> </tt> or <tt> boost::hash<Q> </tt>
+            Note that default hash function like <tt> std::hash<Q> </tt>
             is generally not suitable for complex type \p Q and its derivatives.
             You should manually provide particular hash functor for such types.
         */
@@ -56,7 +55,7 @@ namespace cds { namespace opt {
                 template <typename Q>
                 size_t operator()( Q const& key ) const
                 {
-                    return hash<Q>()( key );
+                    return std::hash<Q>()( key );
                 }
             };
         };
@@ -107,19 +106,13 @@ namespace cds { namespace opt {
 
     //@cond
     // At least, two functors must be provided. Single functor is not supported
-//#if CDS_COMPILER != CDS_COMPILER_INTEL
-    // Intel C++ compiler does not support
     template <typename Functor> struct hash< std::tuple<Functor> >;
-//#endif
     //@endcond
 
     /// Multi-functor hash option setter - specialization for std::tuple
     template <typename... Functors>
     struct hash< std::tuple<Functors...> >
     {
-//#   if CDS_COMPILER == CDS_COMPILER_INTEL
-        //static_assert( sizeof...(Functors) > 1, "At least, two functors must be provided. Single functor is not supported" );
-//#   endif
         //@cond
         template <typename Base> struct pack: public Base
         {
index 9412ebc..6721fb0 100644 (file)
     <ClInclude Include="..\..\..\cds\details\binary_functor_wrapper.h" />\r
     <ClInclude Include="..\..\..\cds\details\bit_reverse_counter.h" />\r
     <ClInclude Include="..\..\..\cds\details\bounded_container.h" />\r
-    <ClInclude Include="..\..\..\cds\details\hash_functor_selector.h" />\r
     <ClInclude Include="..\..\..\cds\details\lib.h" />\r
     <ClInclude Include="..\..\..\cds\details\numtraits.h" />\r
     <ClInclude Include="..\..\..\cds\details\static_functor.h" />\r
index b5de3f4..2d31925 100644 (file)
     <ClInclude Include="..\..\..\cds\details\bounded_container.h">\r
       <Filter>Header Files\cds\details</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\details\hash_functor_selector.h">\r
-      <Filter>Header Files\cds\details</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\gc\all.h">\r
       <Filter>Header Files\cds\gc</Filter>\r
     </ClInclude>\r
index 2301649..59a149c 100644 (file)
@@ -2,12 +2,12 @@
 
 // Pass The Buck (PTB) Memory manager implementation
 
+#include <algorithm>   // std::fill
+#include <functional>  // std::hash
+
 #include <cds/gc/ptb/ptb.h>
 #include <cds/algo/int_algo.h>
 
-#include <cds/details/hash_functor_selector.h>
-#include <algorithm>   // std::fill
-
 namespace cds { namespace gc { namespace ptb {
 
     namespace details {
@@ -25,7 +25,7 @@ namespace cds { namespace gc { namespace ptb {
             }
             item_type&  bucket( guard_data::guarded_ptr p )
             {
-                return m_Buckets[ cds::details::hash<guard_data::guarded_ptr>()( p ) & (m_nBucketCount - 1)  ];
+                return m_Buckets[ std::hash<guard_data::guarded_ptr>()( p ) & (m_nBucketCount - 1)  ];
             }
 
         public:
index 6a8e3a4..a63abd3 100644 (file)
@@ -83,32 +83,26 @@ namespace std {
             return false;
         }
     };
-} // namespace std
-
-CDS_BEGIN_STD_HASH_NAMESPACE
-template <>
-struct hash<map2::key_thread>
-{
-    typedef size_t              result_type;
-    typedef map2::key_thread    argument_type;
 
-    size_t operator()(map2::key_thread const& k) const
-    {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
-    }
-    size_t operator()(size_t k) const
+    template <>
+    struct hash<map2::key_thread>
     {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k );
-    }
-};
-CDS_END_STD_HASH_NAMESPACE
+        typedef size_t              result_type;
+        typedef map2::key_thread    argument_type;
 
-namespace boost {
-    inline size_t hash_value( map2::key_thread const& k )
-    {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
-    }
+        size_t operator()( map2::key_thread const& k ) const
+        {
+            return std::hash<size_t>()(k.nKey);
+        }
+        size_t operator()( size_t k ) const
+        {
+            return std::hash<size_t>()(k);
+        }
+    };
+} // namespace std
 
+/*
+namespace boost {
     template <>
     struct hash<map2::key_thread>
     {
@@ -125,6 +119,7 @@ namespace boost {
         }
     };
 } // namespace boost
+*/
 
 namespace map2 {
 
index d5dab92..d2604c8 100644 (file)
@@ -83,30 +83,30 @@ namespace std {
             return false;
         }
     };
-} // namespace std
 
-CDS_BEGIN_STD_HASH_NAMESPACE
     template <>
     struct hash<set2::key_thread>
     {
         typedef size_t              result_type;
         typedef set2::key_thread    argument_type;
 
-        size_t operator()(set2::key_thread const& k) const
+        size_t operator()( set2::key_thread const& k ) const
         {
-            return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
+            return std::hash<size_t>()(k.nKey);
         }
-        size_t operator()(size_t k) const
+        size_t operator()( size_t k ) const
         {
-            return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k );
+            return std::hash<size_t>()(k);
         }
     };
-CDS_END_STD_HASH_NAMESPACE
 
+} // namespace std
+
+/*
 namespace boost {
     inline size_t hash_value( set2::key_thread const& k )
     {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
+        return std::hash<size_t>()( k.nKey );
     }
 
     template <>
@@ -125,7 +125,7 @@ namespace boost {
         }
     };
 } // namespace boost
-
+*/
 
 namespace set2 {