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 d0a8d8546df0c113a5d045fc4ea7223feaed343b..bd94dab3b51460122d51ddd48040dfccc316e055 100644 (file)
@@ -286,7 +286,7 @@ namespace cds { namespace intrusive {
                 // the heap is empty
                 m_Lock.unlock();
                 m_Stat.onPopFailed();
                 // the heap is empty
                 m_Lock.unlock();
                 m_Stat.onPopFailed();
-                return false;
+                return nullptr;
             }
             counter_type nBottom = m_ItemCounter.reversed_value();
             m_ItemCounter.dec();
             }
             counter_type nBottom = m_ItemCounter.reversed_value();
             m_ItemCounter.dec();
index 18fe4bbb339dc3f0dc52449ae69c7e3a9f48c04c..bd40719555c1918992751db0394ae131ca09d166 100644 (file)
@@ -4,8 +4,8 @@
 #define __CDS_OPT_HASH_H
 
 #include <tuple>
 #define __CDS_OPT_HASH_H
 
 #include <tuple>
+#include<functional>
 #include <cds/opt/options.h>
 #include <cds/opt/options.h>
-#include <cds/details/hash_functor_selector.h>
 
 namespace cds { namespace opt {
 
 
 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.
         /**
             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.
         */
             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
                 {
                 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
 
     //@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> >;
     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...> >
     {
     //@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
         {
         //@cond
         template <typename Base> struct pack: public Base
         {
index 9412ebc63099ae6aad013146b5667dd8da088909..6721fb0703092d68921b6909fdcb9af0d4dfb687 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\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
     <ClInclude Include="..\..\..\cds\details\lib.h" />\r
     <ClInclude Include="..\..\..\cds\details\numtraits.h" />\r
     <ClInclude Include="..\..\..\cds\details\static_functor.h" />\r
index b5de3f4b9dc8806ccfb35417a7cd8fd7b59e3a06..2d319256aff76079638c5cec56ec979cd9dc1626 100644 (file)
     <ClInclude Include="..\..\..\cds\details\bounded_container.h">\r
       <Filter>Header Files\cds\details</Filter>\r
     </ClInclude>\r
     <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
     <ClInclude Include="..\..\..\cds\gc\all.h">\r
       <Filter>Header Files\cds\gc</Filter>\r
     </ClInclude>\r
index 2301649865be3513d4142280d783d58f68f2d8bb..59a149c29221d5091ab78ab06bf95911662cccb3 100644 (file)
@@ -2,12 +2,12 @@
 
 // Pass The Buck (PTB) Memory manager implementation
 
 
 // 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/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 {
 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 )
             {
             }
             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:
             }
 
         public:
index 6a8e3a48d9b0fbb3df46994c66fb59f5b2e0fbdd..a63abd323069df01e3a3f03fe6fd6e8d88580b7a 100644 (file)
@@ -83,32 +83,26 @@ namespace std {
             return false;
         }
     };
             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>
     {
     template <>
     struct hash<map2::key_thread>
     {
@@ -125,6 +119,7 @@ namespace boost {
         }
     };
 } // namespace boost
         }
     };
 } // namespace boost
+*/
 
 namespace map2 {
 
 
 namespace map2 {
 
index d5dab928fe38cd314bc9d4c949020971c40d8b99..d2604c8033d6328e791ee53d1676fe191d056640 100644 (file)
@@ -83,30 +83,30 @@ namespace std {
             return false;
         }
     };
             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;
 
     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 )
     {
 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 <>
     }
 
     template <>
@@ -125,7 +125,7 @@ namespace boost {
         }
     };
 } // namespace boost
         }
     };
 } // namespace boost
-
+*/
 
 namespace set2 {
 
 
 namespace set2 {