Tried to fix gcc/clang problem like how to pass argument pack to lambda function
[libcds.git] / cds / container / striped_set / std_set.h
index 96be8780d2982ade9e0ee356f3d05d5bec01c520..a132aaee9071b2117613ee9da6dd54da061d77b6 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H
-#define __CDS_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H
+#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H
+#define CDSLIB_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H
 
 #include <cds/container/striped_set/adapter.h>
 #include <set>
@@ -27,7 +27,6 @@ namespace cds { namespace container {
         struct swap_item_policy< std::set< T, Traits, Alloc > >: public copy_item_policy< std::set< T, Traits, Alloc > >
         {};
 
-#ifdef CDS_MOVE_SEMANTICS_SUPPORT
         // Move policy for std::set
         template <typename T, typename Traits, typename Alloc>
         struct move_item_policy< std::set< T, Traits, Alloc > >
@@ -40,15 +39,14 @@ namespace cds { namespace container {
                 set.insert( std::move( *itWhat ) );
             }
         };
-#endif
     }   // namespace striped_set
 }} // namespace cds::container
 
 namespace cds { namespace intrusive { namespace striped_set {
 
     /// std::set adapter for hash set bucket
-    template <typename T, class Traits, class Alloc, CDS_SPEC_OPTIONS>
-    class adapt< std::set<T, Traits, Alloc>, CDS_OPTIONS >
+    template <typename T, class Traits, class Alloc, typename... Options>
+    class adapt< std::set<T, Traits, Alloc>, Options... >
     {
     public:
         typedef std::set<T, Traits, Alloc>     container_type          ;   ///< underlying container type
@@ -71,14 +69,12 @@ namespace cds { namespace intrusive { namespace striped_set {
                 typename cds::opt::value<
                     typename cds::opt::find_option<
                         cds::opt::copy_policy< cds::container::striped_set::move_item >
-                        , CDS_OPTIONS
+                        , Options...
                     >::type
                 >::copy_policy
                 , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
                 , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type>
-#ifdef CDS_MOVE_SEMANTICS_SUPPORT
                 , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
-#endif
             >::type copy_item;
             //@endcond
 
@@ -94,29 +90,22 @@ namespace cds { namespace intrusive { namespace striped_set {
             {
                 std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
                 if ( res.second )
-                    ::cds::unref(f)( const_cast<value_type&>(*res.first) );
+                    f( const_cast<value_type&>(*res.first) );
                 return res.second;
             }
 
-#       ifdef CDS_EMPLACE_SUPPORT
             template <typename... Args>
             bool emplace( Args&&... args )
             {
-#           if CDS_COMPILER == CDS_COMPILER_GCC && CDS_COMPILER_VERSION < 40800 || CDS_COMPILER == CDS_COMPILER_CLANG && !defined(__LIBCPP_VERSION)
-                // GCC < 4.8: std::set has no "emplace" member function. Emulate it
-                std::pair<iterator, bool> res = m_Set.insert( value_type( std::forward<Args>(args)...));
-#           else
                 std::pair<iterator, bool> res = m_Set.emplace( std::forward<Args>(args)... );
-#           endif
                 return res.second;
             }
-#       endif
 
             template <typename Q, typename Func>
             std::pair<bool, bool> ensure( const Q& val, Func func )
             {
                 std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
-                ::cds::unref(func)( res.second, const_cast<value_type&>(*res.first), val );
+                func( res.second, const_cast<value_type&>(*res.first), val );
                 return std::make_pair( true, res.second );
             }
 
@@ -126,7 +115,7 @@ namespace cds { namespace intrusive { namespace striped_set {
                 iterator it = m_Set.find( value_type(key) );
                 if ( it == m_Set.end() )
                     return false;
-                ::cds::unref(f)( const_cast<value_type&>(*it) );
+                f( const_cast<value_type&>(*it) );
                 m_Set.erase( it );
                 return true;
             }
@@ -137,7 +126,7 @@ namespace cds { namespace intrusive { namespace striped_set {
                 iterator it = m_Set.find( value_type(val) );
                 if ( it == m_Set.end() )
                     return false;
-                ::cds::unref(f)( const_cast<value_type&>(*it), val );
+                f( const_cast<value_type&>(*it), val );
                 return true;
             }
 
@@ -172,4 +161,4 @@ namespace cds { namespace intrusive { namespace striped_set {
 
 //@endcond
 
-#endif // #ifndef __CDS_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H
+#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_SET_ADAPTER_H