Remove CDS_CXX11_LAMBDA_SUPPORT macro and a lot of emulating code
[libcds.git] / cds / container / lazy_kvlist_impl.h
index 66179fe0d94820c56c7c316fa14b33690fef748e..30b8b9b32b6497eb5c9175d1d2d5b7ecf9a5fa6f 100644 (file)
@@ -136,72 +136,6 @@ namespace cds { namespace container {
         /// Guarded pointer
         typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
 
-    private:
-        //@cond
-#   ifndef CDS_CXX11_LAMBDA_SUPPORT
-        template <typename Func>
-        class insert_functor: protected cds::details::functor_wrapper<Func>
-        {
-            typedef cds::details::functor_wrapper<Func> base_class;
-        public:
-            insert_functor ( Func f )
-                : base_class( f )
-            {}
-
-            void operator()( node_type& node )
-            {
-                base_class::get()( node.m_Data );
-            }
-        };
-
-        template <typename Func>
-        class ensure_functor: protected cds::details::functor_wrapper<Func>
-        {
-            typedef cds::details::functor_wrapper<Func> base_class;
-        public:
-            ensure_functor( Func f )
-                : base_class(f)
-            {}
-
-            void operator ()( bool bNew, node_type& node, node_type& )
-            {
-                base_class::get()( bNew, node.m_Data );
-            }
-        };
-
-        template <typename Func>
-        class find_functor: protected cds::details::functor_wrapper<Func>
-        {
-            typedef cds::details::functor_wrapper<Func> base_class;
-        public:
-            find_functor( Func f )
-                : base_class(f)
-            {}
-
-            template <typename Q>
-            void operator ()( node_type& node, Q&  )
-            {
-                base_class::get()( node.m_Data );
-            }
-        };
-
-        template <typename Func>
-        struct erase_functor
-        {
-            Func m_func;
-
-            erase_functor( Func f )
-                : m_func( f )
-            {}
-
-            void operator ()( node_type const & node )
-            {
-                cds::unref(m_func)( const_cast<value_type&>(node.m_Data) );
-            }
-        };
-#   endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-        //@endcond
-
     protected:
         //@cond
         template <typename K>
@@ -216,13 +150,11 @@ namespace cds { namespace container {
             return cxx_allocator().New( key, val );
         }
 
-#ifdef CDS_EMPLACE_SUPPORT
         template <typename... Args>
         static node_type * alloc_node( Args&&... args )
         {
             return cxx_allocator().MoveNew( std::forward<Args>(args)... );
         }
-#endif
 
         static void free_node( node_type * pNode )
         {
@@ -504,20 +436,15 @@ namespace cds { namespace container {
             return insert_key_at( head(), key, func );
         }
 
-#   ifdef CDS_EMPLACE_SUPPORT
         /// Inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
         /**
             Returns \p true if inserting successful, \p false otherwise.
-
-            @note This function is available only for compiler that supports
-            variadic template and move semantics
         */
         template <typename... Args>
         bool emplace( Args&&... args )
         {
             return emplace_at( head(), std::forward<Args>(args)... );
         }
-#   endif
 
         /// Ensures that the \p key exists in the list
         /**
@@ -833,26 +760,18 @@ namespace cds { namespace container {
         {
             scoped_node_ptr pNode( alloc_node( key ));
 
-#   ifdef CDS_CXX11_LAMBDA_SUPPORT
-            if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } ))
-#   else
-            insert_functor<Func>  wrapper( f );
-            if ( base_class::insert_at( &refHead, *pNode, cds::ref(wrapper) ))
-#   endif
-            {
+            if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } )) {
                 pNode.release();
                 return true;
             }
             return false;
         }
 
-#   ifdef CDS_EMPLACE_SUPPORT
         template <typename... Args>
         bool emplace_at( head_type& refHead, Args&&... args )
         {
             return insert_node_at( refHead, alloc_node( std::forward<Args>(args)... ));
         }
-#   endif
 
         template <typename K, typename Compare>
         bool erase_at( head_type& refHead, K const& key, Compare cmp )
@@ -863,12 +782,7 @@ namespace cds { namespace container {
         template <typename K, typename Compare, typename Func>
         bool erase_at( head_type& refHead, K const& key, Compare cmp, Func f )
         {
-#   ifdef CDS_CXX11_LAMBDA_SUPPORT
             return base_class::erase_at( &refHead, key, cmp, [&f](node_type const & node){cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
-#   else
-            erase_functor<Func> wrapper( f );
-            return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) );
-#   endif
         }
 
         template <typename K, typename Compare>
@@ -882,13 +796,8 @@ namespace cds { namespace container {
         {
             scoped_node_ptr pNode( alloc_node( key ));
 
-#   ifdef CDS_CXX11_LAMBDA_SUPPORT
             std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
                 [&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
-#   else
-            ensure_functor<Func> wrapper( f );
-            std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper));
-#   endif
             if ( ret.first && ret.second )
                 pNode.release();
 
@@ -904,12 +813,7 @@ namespace cds { namespace container {
         template <typename K, typename Compare, typename Func>
         bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
         {
-#   ifdef CDS_CXX11_LAMBDA_SUPPORT
             return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K& ){ cds::unref(f)( node.m_Data ); });
-#   else
-            find_functor<Func>  wrapper( f );
-            return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) );
-#   endif
         }
 
         template <typename K, typename Compare>