From 7dac077c1f71d753e833caf9a8db36e3ad5793e7 Mon Sep 17 00:00:00 2001 From: khizmax Date: Wed, 24 Sep 2014 15:29:49 +0400 Subject: [PATCH] Remove CDS_CXX11_LAMBDA_SUPPORT macro and a lot of emulating code --- cds/compiler/clang/defs.h | 3 - cds/compiler/defs.h | 1 + cds/compiler/gcc/defs.h | 3 - cds/compiler/icl/defs.h | 3 - cds/compiler/vc/defs.h | 3 - cds/container/cuckoo_map.h | 97 +----------- cds/container/cuckoo_set.h | 101 +----------- cds/container/ellen_bintree_map_impl.h | 120 +-------------- cds/container/ellen_bintree_map_rcu.h | 120 +-------------- cds/container/ellen_bintree_set_impl.h | 113 +------------- cds/container/ellen_bintree_set_rcu.h | 113 +------------- cds/container/lazy_kvlist_impl.h | 89 +---------- cds/container/lazy_kvlist_nogc.h | 46 ------ cds/container/lazy_kvlist_rcu.h | 100 +----------- cds/container/lazy_list_impl.h | 128 +--------------- cds/container/lazy_list_nogc.h | 25 --- cds/container/lazy_list_rcu.h | 139 +---------------- cds/container/michael_kvlist_impl.h | 89 +---------- cds/container/michael_kvlist_nogc.h | 46 ------ cds/container/michael_kvlist_rcu.h | 100 +----------- cds/container/michael_list_impl.h | 128 +--------------- cds/container/michael_list_nogc.h | 25 --- cds/container/michael_list_rcu.h | 139 +---------------- cds/container/mspriority_queue.h | 31 ---- cds/container/skip_list_map_impl.h | 125 +-------------- cds/container/skip_list_map_rcu.h | 144 +----------------- cds/container/skip_list_set_impl.h | 122 +-------------- cds/container/skip_list_set_nogc.h | 31 ---- cds/container/skip_list_set_rcu.h | 138 +---------------- cds/container/split_list_map.h | 50 +----- cds/container/split_list_map_rcu.h | 47 ------ cds/container/split_list_set.h | 92 +---------- cds/container/split_list_set_nogc.h | 17 --- cds/container/split_list_set_rcu.h | 101 +----------- cds/container/striped_map.h | 67 -------- cds/container/striped_set.h | 33 ---- cds/container/vyukov_mpmc_cycle_queue.h | 13 -- cds/intrusive/cuckoo_set.h | 61 -------- cds/intrusive/ellen_bintree_impl.h | 92 ----------- cds/intrusive/ellen_bintree_rcu.h | 52 ------- cds/intrusive/lazy_list_impl.h | 20 +-- cds/intrusive/lazy_list_rcu.h | 31 ---- cds/intrusive/michael_list_impl.h | 11 -- cds/intrusive/michael_list_rcu.h | 32 ---- cds/intrusive/mspriority_queue.h | 15 -- cds/intrusive/skip_list_impl.h | 129 +--------------- cds/intrusive/skip_list_nogc.h | 57 +------ cds/intrusive/skip_list_rcu.h | 132 +--------------- cds/intrusive/split_list.h | 5 - cds/intrusive/split_list_base.h | 18 --- cds/intrusive/split_list_nogc.h | 5 - cds/intrusive/split_list_rcu.h | 5 - cds/intrusive/striped_set.h | 38 ----- cds/intrusive/striped_set/adapter.h | 11 -- cds/intrusive/striped_set/boost_list.h | 11 -- cds/intrusive/striped_set/boost_slist.h | 12 -- .../striped_set/boost_unordered_set.h | 11 -- cds/intrusive/treiber_stack.h | 20 --- 58 files changed, 38 insertions(+), 3472 deletions(-) diff --git a/cds/compiler/clang/defs.h b/cds/compiler/clang/defs.h index 90757780..41e3e0f3 100644 --- a/cds/compiler/clang/defs.h +++ b/cds/compiler/clang/defs.h @@ -28,9 +28,6 @@ // C++11 inline namespace #define CDS_CXX11_INLINE_NAMESPACE_SUPPORT -// Lambda -#define CDS_CXX11_LAMBDA_SUPPORT - #define CDS_CONSTEXPR constexpr #define CDS_CONSTEXPR_CONST constexpr const diff --git a/cds/compiler/defs.h b/cds/compiler/defs.h index 95290eae..b61b2977 100644 --- a/cds/compiler/defs.h +++ b/cds/compiler/defs.h @@ -6,6 +6,7 @@ /* Required C++11 features: - move semantics [CDS_RVALUE_SUPPORT, CDS_MOVE_SEMANTICS_SUPPORT] + - lambda function [CDS_CXX11_LAMBDA_SUPPORT] - variadic template [CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT] - template alias [CDS_CXX11_TEMPLATE_ALIAS_SUPPORT] - explicit conversion operator [CDS_CXX11_EXPLICIT_CONVERSION_OPERATOR_SUPPORT] diff --git a/cds/compiler/gcc/defs.h b/cds/compiler/gcc/defs.h index de34765a..37e69575 100644 --- a/cds/compiler/gcc/defs.h +++ b/cds/compiler/gcc/defs.h @@ -29,9 +29,6 @@ // C++11 inline namespace #define CDS_CXX11_INLINE_NAMESPACE_SUPPORT -// Lambda -#define CDS_CXX11_LAMBDA_SUPPORT - // constexpr #define CDS_CONSTEXPR constexpr diff --git a/cds/compiler/icl/defs.h b/cds/compiler/icl/defs.h index 50c7e490..9e6e9ec5 100644 --- a/cds/compiler/icl/defs.h +++ b/cds/compiler/icl/defs.h @@ -84,9 +84,6 @@ #define CDS_NOEXCEPT_SUPPORT noexcept #define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr) -// Lambda (ICL 12 +) -#define CDS_CXX11_LAMBDA_SUPPORT - // C++11 inline namespace #define CDS_CXX11_INLINE_NAMESPACE_SUPPORT diff --git a/cds/compiler/vc/defs.h b/cds/compiler/vc/defs.h index 84700abc..ff485b7c 100644 --- a/cds/compiler/vc/defs.h +++ b/cds/compiler/vc/defs.h @@ -87,9 +87,6 @@ #define CDS_NOEXCEPT_SUPPORT #define CDS_NOEXCEPT_SUPPORT_(expr) -// Lambda (VC 10 +) -#define CDS_CXX11_LAMBDA_SUPPORT - // C++11 inline namespace //#define CDS_CXX11_INLINE_NAMESPACE_SUPPORT diff --git a/cds/container/cuckoo_map.h b/cds/container/cuckoo_map.h index f9ae03c7..c80c0e1f 100644 --- a/cds/container/cuckoo_map.h +++ b/cds/container/cuckoo_map.h @@ -374,71 +374,6 @@ namespace cds { namespace container { typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr; -#ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor - { - void operator()( value_type& ) const - {} - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const & v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - template - class insert_key_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_key_wrapper( Func f ): base_class(f) {} - - void operator()( node_type& item ) - { - base_class::get()( item.m_val ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_wrapper( Func f) : base_class(f) {} - - void operator()( bool bNew, node_type& item, node_type const& ) - { - base_class::get()( bNew, item.m_val ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_val, val ); - } - }; -#endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond public: @@ -537,11 +472,7 @@ namespace cds { namespace container { template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, empty_insert_functor() ); -# endif } /// Inserts new node @@ -558,12 +489,7 @@ namespace cds { namespace container { template bool insert( K const& key, V const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [&val](value_type& item) { item.second = val ; } ); -# else - insert_value_functor f(val); - return insert_key( key, cds::ref(f) ); -# endif } /// Inserts new node and initialize it by a functor @@ -598,13 +524,7 @@ namespace cds { namespace container { bool insert_key( const K& key, Func func ) { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_val ); } )) -# else - insert_key_wrapper wrapper(func); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -#endif - { + if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_val ); } )) { pNode.release(); return true; } @@ -661,14 +581,9 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_val ); } ); -# else - ensure_wrapper wrapper( func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -780,12 +695,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_val );}); -# else - find_wrapper wrapper(f); - return base_class::find( key, cds::ref(wrapper) ); -# endif } /// Find the key \p val using \p pred predicate for comparing @@ -799,13 +709,8 @@ namespace cds { namespace container { template bool find_with( K const& key, Predicate pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper(), [&f](node_type& item, K const& ) { cds::unref(f)( item.m_val );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( key, cds::details::predicate_wrapper(), cds::ref(wrapper) ); -# endif } /// Find the key \p key diff --git a/cds/container/cuckoo_set.h b/cds/container/cuckoo_set.h index 8c24b107..348f02df 100644 --- a/cds/container/cuckoo_set.h +++ b/cds/container/cuckoo_set.h @@ -419,62 +419,6 @@ namespace cds { namespace container { typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) const - {} - }; - - struct empty_find_functor { - template - void operator()( node_type& item, Q& val ) const - {} - }; - - template - class insert_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_wrapper( Func f ): base_class(f) {} - - void operator()( node_type& node ) - { - base_class::get()( node.m_val ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - Q const& val; - - ensure_wrapper( Q const& v, Func f) : base_class(f), val(v) {} - - void operator()( bool bNew, node_type& item, node_type const& ) - { - base_class::get()( bNew, item.m_val, val ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_val, val ); - } - }; -# endif //@endcond public: @@ -573,11 +517,7 @@ namespace cds { namespace container { template bool insert( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -603,13 +543,7 @@ namespace cds { namespace container { bool insert( Q const& val, Func f ) { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&f]( node_type& node ) { cds::unref(f)( node.m_val ); } )) -# else - insert_wrapper wrapper( f ); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -# endif - { + if ( base_class::insert( *pNode, [&f]( node_type& node ) { cds::unref(f)( node.m_val ); } )) { pNode.release(); return true; } @@ -665,14 +599,9 @@ namespace cds { namespace container { std::pair ensure( Q const& val, Func func ) { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&val,&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_val, val ); } ); -# else - ensure_wrapper wrapper( val, func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -792,12 +721,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f](node_type& item, Q& v) { cds::unref(f)( item.m_val, v );}); -# else - find_wrapper wrapper(f); - return base_class::find( val, cds::ref(wrapper) ); -# endif } /// Find the key \p val using \p pred predicate for comparing @@ -811,13 +735,8 @@ namespace cds { namespace container { template bool find_with( Q& val, Predicate pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, typename maker::template predicate_wrapper(), [&f](node_type& item, Q& v) { cds::unref(f)( item.m_val, v );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( val, typename maker::template predicate_wrapper(), cds::ref(wrapper) ); -# endif } /// Find the key \p val @@ -844,12 +763,7 @@ namespace cds { namespace container { template bool find( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f](node_type& item, Q const& v) { cds::unref(f)( item.m_val, v );}); -# else - find_wrapper wrapper(f); - return base_class::find( val, cds::ref(wrapper) ); -# endif } /// Find the key \p val using \p pred predicate for comparing @@ -863,13 +777,8 @@ namespace cds { namespace container { template bool find_with( Q const& val, Predicate pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, typename maker::template predicate_wrapper(), [&f](node_type& item, Q const& v) { cds::unref(f)( item.m_val, v );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( val, typename maker::template predicate_wrapper(), cds::ref(wrapper) ); -# endif } /// Find the key \p val @@ -884,11 +793,7 @@ namespace cds { namespace container { template bool find( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [](node_type&, Q const&) {}); -# else - return base_class::find( val, empty_find_functor()); -# endif } /// Find the key \p val using \p pred predicate for comparing @@ -902,11 +807,7 @@ namespace cds { namespace container { template bool find_with( Q const& val, Predicate pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, typename maker::template predicate_wrapper(), [](node_type&, Q const&) {}); -# else - return base_class::find_with( val, typename maker::template predicate_wrapper(), empty_find_functor()); -# endif } /// Clears the set diff --git a/cds/container/ellen_bintree_map_impl.h b/cds/container/ellen_bintree_map_impl.h index a71b7857..8fe59da1 100644 --- a/cds/container/ellen_bintree_map_impl.h +++ b/cds/container/ellen_bintree_map_impl.h @@ -143,89 +143,6 @@ namespace cds { namespace container { /// Guarded pointer typedef cds::gc::guarded_ptr< gc, leaf_node, value_type, details::guarded_ptr_cast_set > guarded_ptr; - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor - { - void operator()( value_type& ) const - {} - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const& v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - template - class insert_key_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_key_wrapper( Func f ): base_class(f) {} - - void operator()( leaf_node& item ) - { - base_class::get()( item.m_Value ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_wrapper( Func f) : base_class(f) {} - - void operator()( bool bNew, leaf_node& item, leaf_node const& ) - { - base_class::get()( bNew, item.m_Value ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( leaf_node& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( leaf_node& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; -# endif - //@endcond - public: /// Default constructor EllenBinTreeMap() @@ -252,11 +169,7 @@ namespace cds { namespace container { template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, empty_insert_functor() ); -# endif } /// Inserts new node @@ -314,13 +227,7 @@ namespace cds { namespace container { bool insert_key( const K& key, Func func ) { scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) -# else - insert_key_wrapper wrapper(func); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -#endif - { + if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) { pNode.release(); return true; } @@ -377,14 +284,9 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&func](bool bNew, leaf_node& item, leaf_node const& ){ cds::unref(func)( bNew, item.m_Value ); } ); -# else - ensure_wrapper wrapper( func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -433,12 +335,7 @@ namespace cds { namespace container { template bool erase( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the map using \p pred predicate for searching @@ -451,13 +348,8 @@ namespace cds { namespace container { template bool erase_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts an item with minimal key from the map @@ -549,12 +441,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find( key, cds::ref(wrapper) ); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -567,13 +454,8 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper) ); -# endif } /// Find the key \p key diff --git a/cds/container/ellen_bintree_map_rcu.h b/cds/container/ellen_bintree_map_rcu.h index 4bab281a..c61a01cb 100644 --- a/cds/container/ellen_bintree_map_rcu.h +++ b/cds/container/ellen_bintree_map_rcu.h @@ -144,89 +144,6 @@ namespace cds { namespace container { cds::urcu::details::conventional_exempt_member_cast > exempt_ptr; - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor - { - void operator()( value_type& ) const - {} - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const& v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - template - class insert_key_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_key_wrapper( Func f ): base_class(f) {} - - void operator()( leaf_node& item ) - { - base_class::get()( item.m_Value ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_wrapper( Func f) : base_class(f) {} - - void operator()( bool bNew, leaf_node& item, leaf_node const& ) - { - base_class::get()( bNew, item.m_Value ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( leaf_node& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( leaf_node& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; -# endif - //@endcond - public: /// Default constructor EllenBinTreeMap() @@ -253,11 +170,7 @@ namespace cds { namespace container { template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, empty_insert_functor() ); -# endif } /// Inserts new node @@ -319,13 +232,7 @@ namespace cds { namespace container { bool insert_key( const K& key, Func func ) { scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) -# else - insert_key_wrapper wrapper(func); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -#endif - { + if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) { pNode.release(); return true; } @@ -386,14 +293,9 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&func](bool bNew, leaf_node& item, leaf_node const& ){ cds::unref(func)( bNew, item.m_Value ); } ); -# else - ensure_wrapper wrapper( func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -446,12 +348,7 @@ namespace cds { namespace container { template bool erase( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the map using \p pred predicate for searching @@ -464,13 +361,8 @@ namespace cds { namespace container { template bool erase_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts an item with minimal key from the map @@ -571,12 +463,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find( key, cds::ref(wrapper) ); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -589,13 +476,8 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper) ); -# endif } /// Find the key \p key diff --git a/cds/container/ellen_bintree_set_impl.h b/cds/container/ellen_bintree_set_impl.h index ea2a0071..739d3a0b 100644 --- a/cds/container/ellen_bintree_set_impl.h +++ b/cds/container/ellen_bintree_set_impl.h @@ -175,74 +175,6 @@ namespace cds { namespace container { /// Guarded pointer typedef cds::gc::guarded_ptr< gc, leaf_node, value_type, details::guarded_ptr_cast_set > guarded_ptr; - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( leaf_node& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, leaf_node& node, leaf_node& ) - { - cds::unref(m_func)( bNew, node.m_Value, m_arg ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( leaf_node const& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( leaf_node& node, Q& val ) - { - cds::unref(m_func)( node.m_Value, val ); - } - }; -#endif - //@endcond - public: /// Default constructor EllenBinTreeSet() @@ -297,13 +229,7 @@ namespace cds { namespace container { bool insert( Q const& val, Func f ) { scoped_node_ptr sp( cxx_leaf_node_allocator().New( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) -# else - insert_functor wrapper(f); - if ( base_class::insert( *sp, cds::ref(wrapper) )) -# endif - { + if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) { sp.release(); return true; } @@ -345,13 +271,8 @@ namespace cds { namespace container { std::pair ensure( const Q& val, Func func ) { scoped_node_ptr sp( cxx_leaf_node_allocator().New( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRes = base_class::ensure( *sp, [&func, &val](bool bNew, leaf_node& node, leaf_node&){ cds::unref(func)( bNew, node.m_Value, val ); }); -# else - ensure_functor wrapper( val, func ); - std::pair bRes = base_class::ensure( *sp, cds::ref(wrapper)); -# endif if ( bRes.first && bRes.second ) sp.release(); return bRes; @@ -423,12 +344,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -441,13 +357,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts an item with minimal key from the set @@ -549,12 +460,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -567,14 +473,8 @@ namespace cds { namespace container { template bool find_with( Q& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val @@ -604,12 +504,7 @@ namespace cds { namespace container { template bool find( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -622,14 +517,8 @@ namespace cds { namespace container { template bool find_with( Q const& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val diff --git a/cds/container/ellen_bintree_set_rcu.h b/cds/container/ellen_bintree_set_rcu.h index 579da7a9..949f5c09 100644 --- a/cds/container/ellen_bintree_set_rcu.h +++ b/cds/container/ellen_bintree_set_rcu.h @@ -176,74 +176,6 @@ namespace cds { namespace container { cds::urcu::details::conventional_exempt_member_cast > exempt_ptr; - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( leaf_node& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, leaf_node& node, leaf_node& ) - { - cds::unref(m_func)( bNew, node.m_Value, m_arg ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( leaf_node const& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( leaf_node& node, Q& val ) - { - cds::unref(m_func)( node.m_Value, val ); - } - }; -#endif - //@endcond - public: /// Default constructor EllenBinTreeSet() @@ -300,13 +232,7 @@ namespace cds { namespace container { bool insert( Q const& val, Func f ) { scoped_node_ptr sp( cxx_leaf_node_allocator().New( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) -# else - insert_functor wrapper(f); - if ( base_class::insert( *sp, cds::ref(wrapper) )) -# endif - { + if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) { sp.release(); return true; } @@ -350,13 +276,8 @@ namespace cds { namespace container { std::pair ensure( const Q& val, Func func ) { scoped_node_ptr sp( cxx_leaf_node_allocator().New( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRes = base_class::ensure( *sp, [&func, &val](bool bNew, leaf_node& node, leaf_node&){ cds::unref(func)( bNew, node.m_Value, val ); }); -# else - ensure_functor wrapper( val, func ); - std::pair bRes = base_class::ensure( *sp, cds::ref(wrapper)); -# endif if ( bRes.first && bRes.second ) sp.release(); return bRes; @@ -436,12 +357,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -454,13 +370,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts an item with minimal key from the set @@ -571,12 +482,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -589,14 +495,8 @@ namespace cds { namespace container { template bool find_with( Q& val, Less pred, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val @@ -628,12 +528,7 @@ namespace cds { namespace container { template bool find( Q const& val, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -646,14 +541,8 @@ namespace cds { namespace container { template bool find_with( Q const& val, Less pred, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val diff --git a/cds/container/lazy_kvlist_impl.h b/cds/container/lazy_kvlist_impl.h index 7589cbbe..30b8b9b3 100644 --- a/cds/container/lazy_kvlist_impl.h +++ b/cds/container/lazy_kvlist_impl.h @@ -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 > guarded_ptr; - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor ( Func f ) - : base_class( f ) - {} - - void operator()( node_type& node ) - { - base_class::get()( node.m_Data ); - } - }; - - template - class ensure_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper 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 - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; - - template - 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(node.m_Data) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: //@cond template @@ -826,13 +760,7 @@ 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 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; } @@ -854,12 +782,7 @@ namespace cds { namespace container { template 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(node.m_Data)); }); -# else - erase_functor wrapper( f ); - return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -873,13 +796,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair 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 wrapper( f ); - std::pair ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -895,12 +813,7 @@ namespace cds { namespace container { template 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 wrapper( f ); - return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/lazy_kvlist_nogc.h b/cds/container/lazy_kvlist_nogc.h index eba231af..03e2b392 100644 --- a/cds/container/lazy_kvlist_nogc.h +++ b/cds/container/lazy_kvlist_nogc.h @@ -92,41 +92,6 @@ namespace cds { namespace container { typedef typename base_class::node_type head_type; //@endcond - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct ensure_functor - { - node_type * m_pItemFound; - - ensure_functor() - : m_pItemFound( nullptr ) - {} - - void operator ()(bool, node_type& item, node_type& ) - { - m_pItemFound = &item; - } - }; - - template - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: //@cond template @@ -566,13 +531,7 @@ namespace cds { namespace container { scoped_node_ptr pNode( alloc_node( key )); node_type * pItemFound = nullptr; -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair ret = base_class::ensure_at( &refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; } ); -# else - ensure_functor func; - std::pair ret = base_class::ensure_at( &refHead, *pNode, boost::ref(func) ); - pItemFound = func.m_pItemFound; -# endif if ( ret.first && ret.second ) pNode.release(); @@ -596,12 +555,7 @@ namespace cds { namespace container { template 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 const& ){ cds::unref(f)( node.m_Data ); }); -# else - find_functor wrapper( f ); - return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } */ //@endcond diff --git a/cds/container/lazy_kvlist_rcu.h b/cds/container/lazy_kvlist_rcu.h index 6dfb17e8..e854631d 100644 --- a/cds/container/lazy_kvlist_rcu.h +++ b/cds/container/lazy_kvlist_rcu.h @@ -140,79 +140,6 @@ namespace cds { namespace container { cds::urcu::details::conventional_exempt_pair_cast > exempt_ptr; - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor ( Func f ) - : base_class( f ) - {} - - void operator()( node_type& node ) - { - base_class::get()( node.m_Data ); - } - }; - - template - class ensure_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper 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 - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; - - struct empty_find_functor - { - template - void operator ()( node_type& node, Q& val ) const - {} - }; - - template - 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(node.m_Data) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: //@cond template @@ -842,13 +769,7 @@ 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 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; } @@ -870,12 +791,7 @@ namespace cds { namespace container { template 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(node.m_Data)); }); -# else - erase_functor wrapper( f ); - return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -883,13 +799,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair 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 wrapper( f ); - std::pair ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -905,22 +816,13 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, K const& key, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_at( &refHead, key, cmp, [](node_type&, K const&) {} ); -# else - return base_class::find_at( &refHead, key, cmp, empty_find_functor() ); -# endif } template bool find_at( head_type& refHead, K& key, Compare cmp, Func f ) const { -# 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 wrapper( f ); - return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/lazy_list_impl.h b/cds/container/lazy_list_impl.h index 51784f6f..0b0b67cf 100644 --- a/cds/container/lazy_list_impl.h +++ b/cds/container/lazy_list_impl.h @@ -135,9 +135,6 @@ namespace cds { namespace container { typedef typename options::type_traits::compare intrusive_key_comparator; typedef typename base_class::node_type head_type; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - typedef typename base_class::empty_erase_functor empty_erase_functor; -# endif //@endcond public: @@ -154,71 +151,6 @@ namespace cds { namespace container { { return n.m_Value; } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; - - template - struct ensure_functor - { - Func m_func; - const Q& m_arg; - - ensure_functor( const Q& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node_to_value(node), m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node_to_value(node), val ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond protected: @@ -524,11 +456,7 @@ namespace cds { namespace container { template bool erase( Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} ); -# else - return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() ); -# endif } /// Deletes the item from the list using \p pred predicate for searching @@ -541,11 +469,7 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, typename options::template less_wrapper::type(), [](value_type const&){} ); -# else - return erase_at( head(), key, typename options::template less_wrapper::type(), empty_erase_functor() ); -# endif } /// Deletes \p key from the list @@ -846,20 +770,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - if ( base_class::insert_at( &refHead, *pNode, [&f,n2v](node_type& node){ cds::unref(f)( n2v(node) ); } )) -# else - if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } )) -# endif -# else - insert_functor 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_to_value(node) ); } )) { pNode.release(); return true; } @@ -869,19 +780,7 @@ namespace cds { namespace container { template bool erase_at( head_type& refHead, const Q& key, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type const& (* n2v)( node_type const& ) = node_to_value; - return base_class::erase_at( &refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } ); -# else return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } ); -# endif -# else - erase_functor wrapper( f ); - return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -895,21 +794,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - std::pair ret = base_class::ensure_at( &refHead, *pNode, - [&f, &key, n2v](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, n2v(node), key ); }); -# else std::pair ret = base_class::ensure_at( &refHead, *pNode, [&f, &key](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, node_to_value(node), key ); }); -# endif -# else - ensure_functor wrapper( key, f ); - std::pair ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -925,19 +811,7 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - return base_class::find_at( &refHead, val, cmp, [&f,n2v](node_type& node, Q& val){ cds::unref(f)( n2v(node), val ); }); -# else return base_class::find_at( &refHead, val, cmp, [&f](node_type& node, Q& val){ cds::unref(f)( node_to_value(node), val ); }); -# endif -# else - find_functor wrapper( f ); - return base_class::find_at( &refHead, val, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/lazy_list_nogc.h b/cds/container/lazy_list_nogc.h index 24bc1552..3a5fbd72 100644 --- a/cds/container/lazy_list_nogc.h +++ b/cds/container/lazy_list_nogc.h @@ -76,25 +76,6 @@ namespace cds { namespace container { typedef typename base_class::node_type head_type; //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct ensure_functor - { - node_type * m_pItemFound; - - ensure_functor() - : m_pItemFound( nullptr ) - {} - - void operator ()(bool, node_type& item, node_type& ) - { - m_pItemFound = &item; - } - }; -# endif - //@endcond - protected: //@cond static node_type * alloc_node() @@ -430,14 +411,8 @@ namespace cds { namespace container { scoped_node_ptr pNode( alloc_node( val )); node_type * pItemFound = nullptr; -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair ret = base_class::ensure_at( &refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; }); -# else - ensure_functor func; - std::pair ret = base_class::ensure_at( &refHead, *pNode, boost::ref(func) ); - pItemFound = func.m_pItemFound; -# endif assert( pItemFound != nullptr ); if ( ret.first && ret.second ) diff --git a/cds/container/lazy_list_rcu.h b/cds/container/lazy_list_rcu.h index 0f95f58d..59fa065b 100644 --- a/cds/container/lazy_list_rcu.h +++ b/cds/container/lazy_list_rcu.h @@ -140,9 +140,6 @@ namespace cds { namespace container { typedef typename maker::type_traits::compare intrusive_key_comparator; typedef typename base_class::node_type head_type; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - typedef typename base_class::empty_erase_functor empty_erase_functor; -# endif //@endcond public: @@ -158,78 +155,6 @@ namespace cds { namespace container { { return n.m_Value; } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node_to_value(node), m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node_to_value(node), val ); - } - }; - - struct empty_find_functor - { - template - void operator ()( node_type& node, Q& val ) const - {} - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond protected: @@ -532,11 +457,7 @@ namespace cds { namespace container { template bool erase( Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} ); -# else - return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() ); -# endif } /// Deletes the item from the list using \p pred predicate for searching @@ -549,11 +470,7 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, typename maker::template less_wrapper::type(), [](value_type const&){} ); -# else - return erase_at( head(), key, typename maker::template less_wrapper::type(), empty_erase_functor() ); -# endif } /// Deletes \p key from the list @@ -875,20 +792,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - if ( base_class::insert_at( &refHead, *pNode, [&f,n2v](node_type& node){ cds::unref(f)( n2v(node) ); } )) -# else - if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } )) -# endif -# else - insert_functor 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_to_value(node) ); } )) { pNode.release(); return true; } @@ -898,19 +802,7 @@ namespace cds { namespace container { template bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type const& (* n2v)( node_type const& ) = node_to_value; - return base_class::erase_at( &refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } ); -# else return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } ); -# endif -# else - erase_functor wrapper( f ); - return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -924,21 +816,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - std::pair ret = base_class::ensure_at( &refHead, *pNode, - [&f, &key, n2v](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, n2v(node), key ); }); -# else std::pair ret = base_class::ensure_at( &refHead, *pNode, [&f, &key](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, node_to_value(node), key ); }); -# endif -# else - ensure_functor wrapper( key, f ); - std::pair ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -948,29 +827,13 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, Q const& key, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_at( &refHead, key, cmp, [](node_type&, Q const &) {} ); -# else - return base_class::find_at( &refHead, key, cmp, empty_find_functor() ); -# endif } template bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - return base_class::find_at( &refHead, val, cmp, [&f,n2v](node_type& node, Q& val){ cds::unref(f)( n2v(node), val ); }); -# else return base_class::find_at( &refHead, val, cmp, [&f](node_type& node, Q& val){ cds::unref(f)( node_to_value(node), val ); }); -# endif -# else - find_functor wrapper( f ); - return base_class::find_at( &refHead, val, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/michael_kvlist_impl.h b/cds/container/michael_kvlist_impl.h index 58926079..f9ae7ee7 100644 --- a/cds/container/michael_kvlist_impl.h +++ b/cds/container/michael_kvlist_impl.h @@ -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 > guarded_ptr; - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor ( Func f ) - : base_class( f ) - {} - - void operator()( node_type& node ) - { - base_class::get()( node.m_Data ); - } - }; - - template - class ensure_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper 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 - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; - - template - 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(node.m_Data) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: //@cond template @@ -812,13 +746,7 @@ 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 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; } @@ -836,13 +764,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair 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 wrapper( f ); - std::pair ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -858,12 +781,7 @@ namespace cds { namespace container { template 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(node.m_Data)); }); -# else - erase_functor wrapper( f ); - return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template bool extract_at( head_type& refHead, typename gc::Guard& dest, K const& key, Compare cmp ) @@ -880,12 +798,7 @@ namespace cds { namespace container { template 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 const&){ cds::unref(f)( node.m_Data ); }); -# else - find_functor wrapper( f ); - return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/michael_kvlist_nogc.h b/cds/container/michael_kvlist_nogc.h index d9407d0c..5a42a8f5 100644 --- a/cds/container/michael_kvlist_nogc.h +++ b/cds/container/michael_kvlist_nogc.h @@ -93,41 +93,6 @@ namespace cds { namespace container { typedef typename base_class::atomic_node_ptr head_type; //@endcond - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct ensure_functor - { - node_type * m_pItemFound; - - ensure_functor() - : m_pItemFound( nullptr ) - {} - - void operator ()(bool, node_type& item, node_type& ) - { - m_pItemFound = &item; - } - }; - - template - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; -# endif - //@endcond - protected: //@cond template @@ -547,13 +512,7 @@ namespace cds { namespace container { scoped_node_ptr pNode( alloc_node( key )); node_type * pItemFound = nullptr; -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair ret = base_class::ensure_at( refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; }); -# else - ensure_functor func; - std::pair ret = base_class::ensure_at( refHead, *pNode, boost::ref(func) ); - pItemFound = func.m_pItemFound; -# endif assert( pItemFound != nullptr ); if ( ret.first && ret.second ) @@ -577,12 +536,7 @@ namespace cds { namespace container { template 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 const& ){ cds::unref(f)( node.m_Data ); }); -# else - find_functor wrapper( f ); - return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } */ //@endcond diff --git a/cds/container/michael_kvlist_rcu.h b/cds/container/michael_kvlist_rcu.h index c0d2cb99..d1aed822 100644 --- a/cds/container/michael_kvlist_rcu.h +++ b/cds/container/michael_kvlist_rcu.h @@ -141,79 +141,6 @@ namespace cds { namespace container { cds::urcu::details::conventional_exempt_pair_cast > exempt_ptr; - private: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor ( Func f ) - : base_class( f ) - {} - - void operator()( node_type& node ) - { - base_class::get()( node.m_Data ); - } - }; - - template - class ensure_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper 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 - class find_functor: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor( Func f ) - : base_class(f) - {} - - template - void operator ()( node_type& node, Q& ) - { - base_class::get()( node.m_Data ); - } - }; - - struct empty_find_functor - { - template - void operator ()( node_type& node, Q& val ) const - {} - }; - - template - 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(node.m_Data) ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: //@cond template @@ -824,13 +751,7 @@ 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 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; } @@ -848,13 +769,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair 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 wrapper( f ); - std::pair ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -870,12 +786,7 @@ namespace cds { namespace container { template 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(node.m_Data)); }); -# else - erase_functor wrapper( f ); - return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -887,22 +798,13 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, K const& key, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_at( refHead, key, cmp, [](node_type&, K const&) {} ); -# else - return base_class::find_at( refHead, key, cmp, empty_find_functor() ); -# endif } template bool find_at( head_type& refHead, K& key, Compare cmp, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_at( refHead, key, cmp, [&f](node_type& node, K const&){ cds::unref(f)( node.m_Data ); }); -# else - find_functor wrapper( f ); - return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/michael_list_impl.h b/cds/container/michael_list_impl.h index d139ef78..60d37b59 100644 --- a/cds/container/michael_list_impl.h +++ b/cds/container/michael_list_impl.h @@ -125,9 +125,6 @@ namespace cds { namespace container { typedef typename options::type_traits::compare intrusive_key_comparator; typedef typename base_class::atomic_node_ptr head_type; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - typedef typename base_class::empty_erase_functor empty_erase_functor; -# endif //@endcond public: @@ -144,71 +141,6 @@ namespace cds { namespace container { { return n.m_Value; } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node_to_value(node), m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node_to_value(node), val ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; -#endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond protected: @@ -495,11 +427,7 @@ namespace cds { namespace container { template bool erase( Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} ); -# else - return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() ); -# endif } /// Deletes the item from the list using \p pred predicate for searching @@ -512,11 +440,7 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, typename options::template less_wrapper::type(), [](value_type const&){} ); -# else - return erase_at( head(), key, typename options::template less_wrapper::type(), empty_erase_functor() ); -# endif } /// Deletes \p key from the list @@ -812,20 +736,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5,4.6,4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - if ( base_class::insert_at( refHead, *pNode, [&f, n2v]( node_type& node ) { cds::unref(f)( n2v(node) ); } )) -# else - if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } )) -# endif -# else - insert_functor 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_to_value(node) ); } )) { pNode.release(); return true; } @@ -841,19 +752,7 @@ namespace cds { namespace container { template bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type const& (* n2v)( node_type const& ) = node_to_value; - return base_class::erase_at( refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } ); -# else return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } ); -# endif -# else - erase_functor wrapper( f ); - return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -867,21 +766,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - std::pair ret = base_class::ensure_at( refHead, *pNode, - [&f, &key, n2v](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, n2v(node), key ); }); -# else std::pair ret = base_class::ensure_at( refHead, *pNode, [&f, &key](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, node_to_value(node), key ); }); -# endif -# else - ensure_functor wrapper( key, f ); - std::pair ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -897,19 +783,7 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - return base_class::find_at( refHead, val, cmp, [&f, n2v](node_type& node, Q& v){ cds::unref(f)( n2v(node), v ); }); -# else return base_class::find_at( refHead, val, cmp, [&f](node_type& node, Q& v){ cds::unref(f)( node_to_value(node), v ); }); -# endif -# else - find_functor wrapper( f ); - return base_class::find_at( refHead, val, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/michael_list_nogc.h b/cds/container/michael_list_nogc.h index 512d6173..170271c0 100644 --- a/cds/container/michael_list_nogc.h +++ b/cds/container/michael_list_nogc.h @@ -75,25 +75,6 @@ namespace cds { namespace container { typedef typename base_class::atomic_node_ptr head_type; //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct ensure_functor - { - node_type * m_pItemFound; - - ensure_functor() - : m_pItemFound( nullptr ) - {} - - void operator ()(bool, node_type& item, node_type& ) - { - m_pItemFound = &item; - } - }; -# endif - //@endcond - protected: //@cond static node_type * alloc_node() @@ -408,13 +389,7 @@ namespace cds { namespace container { scoped_node_ptr pNode( alloc_node( val )); node_type * pItemFound = nullptr; -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair ret = base_class::ensure_at( refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&) { pItemFound = &item; }); -# else - ensure_functor func; - std::pair ret = base_class::ensure_at( refHead, *pNode, boost::ref(func) ); - pItemFound = func.m_pItemFound; -# endif assert( pItemFound != nullptr ); if ( ret.first && ret.second ) diff --git a/cds/container/michael_list_rcu.h b/cds/container/michael_list_rcu.h index 6d8ba102..e3b57975 100644 --- a/cds/container/michael_list_rcu.h +++ b/cds/container/michael_list_rcu.h @@ -131,9 +131,6 @@ namespace cds { namespace container { typedef typename options::type_traits::compare intrusive_key_comparator; typedef typename base_class::atomic_node_ptr head_type; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - typedef typename base_class::empty_erase_functor empty_erase_functor; -# endif //@endcond public: @@ -149,78 +146,6 @@ namespace cds { namespace container { { return n.m_Value; } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node_to_value(node), m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node_to_value(node), val ); - } - }; - - struct empty_find_functor - { - template - void operator ()( node_type& node, Q& val ) const - {} - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node_to_value(node) ); - } - }; -#endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond protected: @@ -501,11 +426,7 @@ namespace cds { namespace container { template bool erase( Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} ); -# else - return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() ); -# endif } /// Deletes the item from the list using \p pred predicate for searching @@ -518,11 +439,7 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( head(), key, typename options::template less_wrapper::type(), [](value_type const&){} ); -# else - return erase_at( head(), key, typename options::template less_wrapper::type(), empty_erase_functor() ); -# endif } /// Deletes \p key from the list @@ -839,20 +756,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5,4.6,4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - if ( base_class::insert_at( refHead, *pNode, [&f, n2v]( node_type& node ) { cds::unref(f)( n2v(node) ); } )) -# else - if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } )) -# endif -# else - insert_functor 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_to_value(node) ); } )) { pNode.release(); return true; } @@ -868,19 +772,7 @@ namespace cds { namespace container { template bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type const& (* n2v)( node_type const& ) = node_to_value; - return base_class::erase_at( refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } ); -# else return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } ); -# endif -# else - erase_functor wrapper( f ); - return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) ); -# endif } template @@ -888,21 +780,8 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - std::pair ret = base_class::ensure_at( refHead, *pNode, - [&f, &key, n2v](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, n2v(node), key ); }); -# else std::pair ret = base_class::ensure_at( refHead, *pNode, [&f, &key](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, node_to_value(node), key ); }); -# endif -# else - ensure_functor wrapper( key, f ); - std::pair ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper)); -# endif if ( ret.first && ret.second ) pNode.release(); @@ -918,29 +797,13 @@ namespace cds { namespace container { template bool find_at( head_type& refHead, Q const& key, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_at( refHead, key, cmp, [](node_type&, Q const &) {} ); -# else - return base_class::find_at( refHead, key, cmp, empty_find_functor() ); -# endif } template bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT -# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA - // GCC 4.5-4.7: node_to_value is unaccessible from lambda, - // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function - value_type& (* n2v)( node_type& ) = node_to_value; - return base_class::find_at( refHead, val, cmp, [&f, n2v](node_type& node, Q& v){ cds::unref(f)( n2v(node), v ); }); -# else return base_class::find_at( refHead, val, cmp, [&f](node_type& node, Q& v){ cds::unref(f)( node_to_value(node), v ); }); -# endif -# else - find_functor wrapper( f ); - return base_class::find_at( refHead, val, cmp, cds::ref(wrapper) ); -# endif } template diff --git a/cds/container/mspriority_queue.h b/cds/container/mspriority_queue.h index 9dd8f133..123bfba9 100644 --- a/cds/container/mspriority_queue.h +++ b/cds/container/mspriority_queue.h @@ -133,30 +133,8 @@ namespace cds { namespace container { { cxx_allocator().Delete( p ); } -# ifndef CDS_CXX11_LAMBDA_SUPPORT - void operator()( value_type& p ) const - { - cxx_allocator().Delete( &p ); - } -# endif }; typedef std::unique_ptr scoped_ptr; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct clear_wrapper - { - Func& func; - clear_wrapper( Func& f ): func(f) {} - - void operator()( value_type& src ) const - { - cds::unref(func)( src ); - value_deleter()( &src ); - } - }; -# endif - //@endcond public: @@ -264,11 +242,7 @@ namespace cds { namespace container { */ void clear() { -# ifdef CDS_CXX11_LAMBDA_SUPPORT base_class::clear_with( []( value_type& src ) { cxx_allocator().Delete( &src ); }); -# else - base_class::clear_with( value_deleter() ); -# endif } /// Clears the queue (not atomic) @@ -288,12 +262,7 @@ namespace cds { namespace container { template void clear_with( Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT base_class::clear_with( [&f]( value_type& val ) { cds::unref(f)(val); value_deleter()( &val ); } ); -# else - clear_wrapper c(f); - base_class::clear_with( cds::ref(c)); -# endif } /// Checks is the priority queue is empty diff --git a/cds/container/skip_list_map_impl.h b/cds/container/skip_list_map_impl.h index 736692cd..10afe27b 100644 --- a/cds/container/skip_list_map_impl.h +++ b/cds/container/skip_list_map_impl.h @@ -172,89 +172,6 @@ namespace cds { namespace container { } //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor - { - void operator()( value_type& ) const - {} - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const & v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - template - class insert_key_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_key_wrapper( Func f ): base_class(f) {} - - void operator()( node_type& item ) - { - base_class::get()( item.m_Value ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_wrapper( Func f) : base_class(f) {} - - void operator()( bool bNew, node_type& item, node_type const& ) - { - base_class::get()( bNew, item.m_Value ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; -# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - public: /// Default ctor SkipListMap() @@ -323,11 +240,7 @@ namespace cds { namespace container { template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, empty_insert_functor() ); -# endif } /// Inserts new node @@ -344,12 +257,7 @@ namespace cds { namespace container { template bool insert( K const& key, V const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [&val](value_type& item) { item.second = val ; } ); -# else - insert_value_functor f(val); - return insert_key( key, cds::ref(f) ); -# endif } /// Inserts new node and initialize it by a functor @@ -384,13 +292,7 @@ namespace cds { namespace container { bool insert_key( const K& key, Func func ) { scoped_node_ptr pNode( node_allocator().New( random_level(), key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) -# else - insert_key_wrapper wrapper(func); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -#endif - { + if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) { pNode.release(); return true; } @@ -447,14 +349,9 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { scoped_node_ptr pNode( node_allocator().New( random_level(), key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_Value ); } ); -# else - ensure_wrapper wrapper( func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -503,12 +400,7 @@ namespace cds { namespace container { template bool erase( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the map using \p pred predicate for searching @@ -521,14 +413,9 @@ namespace cds { namespace container { template bool erase_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts the item from the map with specified \p key @@ -659,12 +546,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find( key, cds::ref(wrapper) ); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -677,14 +559,9 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper) ); -# endif } /// Find the key \p key diff --git a/cds/container/skip_list_map_rcu.h b/cds/container/skip_list_map_rcu.h index 46ce635a..b8e96ec1 100644 --- a/cds/container/skip_list_map_rcu.h +++ b/cds/container/skip_list_map_rcu.h @@ -169,105 +169,6 @@ namespace cds { namespace container { } //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor - { - void operator()( value_type& ) const - {} - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const& v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - template - class insert_key_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_key_wrapper( Func f ): base_class(f) {} - - void operator()( node_type& item ) - { - base_class::get()( item.m_Value ); - } - }; - - template - class ensure_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_wrapper( Func f) : base_class(f) {} - - void operator()( bool bNew, node_type& item, node_type const& ) - { - base_class::get()( bNew, item.m_Value ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - class find_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_wrapper( Func f ) - : base_class(f) - {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; - - template - struct extract_copy_wrapper - { - Func m_func; - extract_copy_wrapper( Func f ) - : m_func(f) - {} - - template - void operator()( Q& dest, node_type& src ) - { - cds::unref(m_func)(dest, src.m_Value); - } - }; - -# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - public: /// Default ctor SkipListMap() @@ -338,11 +239,7 @@ namespace cds { namespace container { template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, empty_insert_functor() ); -# endif } /// Inserts new node @@ -361,14 +258,6 @@ namespace cds { namespace container { template bool insert( K const& key, V const& val ) { - /* -# ifdef CDS_CXX11_LAMBDA_SUPPORT - return insert_key( key, [&val](value_type& item) { item.second = val ; } ); -# else - insert_value_functor f(val); - return insert_key( key, cds::ref(f) ); -# endif - */ scoped_node_ptr pNode( node_allocator().New( random_level(), key, val )); if ( base_class::insert( *pNode )) { @@ -412,13 +301,7 @@ namespace cds { namespace container { bool insert_key( const K& key, Func func ) { scoped_node_ptr pNode( node_allocator().New( random_level(), key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) -# else - insert_key_wrapper wrapper(func); - if ( base_class::insert( *pNode, cds::ref(wrapper) )) -#endif - { + if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) { pNode.release(); return true; } @@ -479,14 +362,9 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { scoped_node_ptr pNode( node_allocator().New( random_level(), key )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair res = base_class::ensure( *pNode, [&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_Value ); } ); -# else - ensure_wrapper wrapper( func ); - std::pair res = base_class::ensure( *pNode, cds::ref(wrapper) ); -# endif if ( res.first && res.second ) pNode.release(); return res; @@ -539,12 +417,7 @@ namespace cds { namespace container { template bool erase( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the map using \p pred predicate for searching @@ -557,13 +430,8 @@ namespace cds { namespace container { template bool erase_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts the item from the map with specified \p key @@ -655,12 +523,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find( key, cds::ref(wrapper) ); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -673,13 +536,8 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );}); -# else - find_wrapper wrapper(f); - return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper) ); -# endif } /// Find the key \p key diff --git a/cds/container/skip_list_set_impl.h b/cds/container/skip_list_set_impl.h index e92b5670..281e44db 100644 --- a/cds/container/skip_list_set_impl.h +++ b/cds/container/skip_list_set_impl.h @@ -161,83 +161,6 @@ namespace cds { namespace container { } //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node.m_Value, m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node.m_Value, val ); - } - }; - - struct copy_value_functor { - template - void operator()( Q& dest, value_type const& src ) const - { - dest = src; - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - - //@endcond - public: /// Default ctor SkipListSet() @@ -334,13 +257,7 @@ namespace cds { namespace container { bool insert( Q const& val, Func f ) { scoped_node_ptr sp( node_allocator().New( random_level(), val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) -# else - insert_functor wrapper(f); - if ( base_class::insert( *sp, cds::ref(wrapper) )) -# endif - { + if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) { sp.release(); return true; } @@ -382,13 +299,8 @@ namespace cds { namespace container { std::pair ensure( const Q& val, Func func ) { scoped_node_ptr sp( node_allocator().New( random_level(), val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRes = base_class::ensure( *sp, [&func, &val](bool bNew, node_type& node, node_type&){ cds::unref(func)( bNew, node.m_Value, val ); }); -# else - ensure_functor wrapper( val, func ); - std::pair bRes = base_class::ensure( *sp, cds::ref(wrapper)); -# endif if ( bRes.first && bRes.second ) sp.release(); return bRes; @@ -462,12 +374,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -480,14 +387,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Extracts the item from the set with specified \p key @@ -627,12 +528,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -645,13 +541,8 @@ namespace cds { namespace container { template bool find_with( Q& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), cds::ref(wrapper)); -# endif } /// Find the key \p val @@ -681,12 +572,7 @@ namespace cds { namespace container { template bool find( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -699,14 +585,8 @@ namespace cds { namespace container { template bool find_with( Q const& val, Less cmp, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val diff --git a/cds/container/skip_list_set_nogc.h b/cds/container/skip_list_set_nogc.h index b549bc15..1aaf6b98 100644 --- a/cds/container/skip_list_set_nogc.h +++ b/cds/container/skip_list_set_nogc.h @@ -168,28 +168,6 @@ namespace cds { namespace container { >::type key_accessor; typedef std::unique_ptr< node_type, typename maker::node_deallocator > scoped_node_ptr; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct ensure_functor - { - node_type * pNode; - void operator ()( bool bNew, node_type& node, node_type& ) - { - pNode = &node; - } - }; - - struct find_functor - { - node_type * pNode; - - template - void operator ()( node_type& node, Q& ) - { - pNode = &node; - } - }; -# endif //@endcond public: @@ -298,21 +276,12 @@ namespace cds { namespace container { std::pair ensure( const Q& val ) { scoped_node_ptr sp( node_allocator().New( base_class::random_level(), val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT node_type * pNode; std::pair bRes = base_class::ensure( *sp, [&pNode](bool, node_type& item, node_type&) { pNode = &item; } ); if ( bRes.first && bRes.second ) sp.release(); assert( pNode ); return std::make_pair( node_to_iterator( pNode ), bRes.second ); -# else - ensure_functor f; - std::pair bRes = base_class::ensure( *sp, cds::ref(f) ); - if ( bRes.first && bRes.second ) - sp.release(); - assert( f.pNode ); - return std::make_pair( node_to_iterator( f.pNode ), bRes.second ); -# endif } /// Searches \p key diff --git a/cds/container/skip_list_set_rcu.h b/cds/container/skip_list_set_rcu.h index 2ea9f497..632f2f9d 100644 --- a/cds/container/skip_list_set_rcu.h +++ b/cds/container/skip_list_set_rcu.h @@ -200,99 +200,6 @@ namespace cds { namespace container { } //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - struct insert_functor - { - Func m_func; - - insert_functor ( Func f ) - : m_func(f) - {} - - void operator()( node_type& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct ensure_functor - { - Func m_func; - Q const& m_arg; - - ensure_functor( Q const& arg, Func f ) - : m_func(f) - , m_arg( arg ) - {} - - void operator ()( bool bNew, node_type& node, node_type& ) - { - cds::unref(m_func)( bNew, node.m_Value, m_arg ); - } - }; - - template - struct find_functor - { - Func m_func; - - find_functor( Func f ) - : m_func(f) - {} - - template - void operator ()( node_type& node, Q& val ) - { - cds::unref(m_func)( node.m_Value, val ); - } - }; - - template - struct erase_functor - { - Func m_func; - - erase_functor( Func f ) - : m_func(f) - {} - - void operator()( node_type const& node ) - { - cds::unref(m_func)( node.m_Value ); - } - }; - - template - struct extract_copy_wrapper - { - Func m_func; - extract_copy_wrapper( Func f ) - : m_func(f) - {} - - template - void operator()( Q& dest, node_type& src ) - { - cds::unref(m_func)(dest, src.m_Value); - } - }; - - struct extract_assign_wrapper - { - template - void operator()( Q& dest, node_type& src ) const - { - dest = src.m_Value; - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - - //@endcond - public: /// Default ctor SkipListSet() @@ -393,13 +300,7 @@ namespace cds { namespace container { bool insert( Q const& val, Func f ) { scoped_node_ptr sp( node_allocator().New( random_level(), val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) -# else - insert_functor wrapper(f); - if ( base_class::insert( *sp, cds::ref(wrapper) )) -# endif - { + if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) { sp.release(); return true; } @@ -443,13 +344,8 @@ namespace cds { namespace container { std::pair ensure( const Q& val, Func func ) { scoped_node_ptr sp( node_allocator().New( random_level(), val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRes = base_class::ensure( *sp, [&func, &val](bool bNew, node_type& node, node_type&){ cds::unref(func)( bNew, node.m_Value, val ); }); -# else - ensure_functor wrapper( val, func ); - std::pair bRes = base_class::ensure( *sp, cds::ref(wrapper)); -# endif if ( bRes.first && bRes.second ) sp.release(); return bRes; @@ -529,12 +425,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase( key, cds::ref(wrapper)); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -547,13 +438,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor wrapper(f); - return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), cds::ref(wrapper)); -# endif } /// Extracts the item from the set with specified \p key @@ -655,12 +541,7 @@ namespace cds { namespace container { template bool find( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -673,14 +554,8 @@ namespace cds { namespace container { template bool find_with( Q& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val @@ -712,12 +587,7 @@ namespace cds { namespace container { template bool find( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); }); -# else - find_functor wrapper(f); - return base_class::find( val, cds::ref(wrapper)); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -730,14 +600,8 @@ namespace cds { namespace container { template bool find_with( Q const& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } ); -# else - find_functor wrapper(f); - return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), - cds::ref(wrapper)); -# endif } /// Find the key \p val diff --git a/cds/container/split_list_map.h b/cds/container/split_list_map.h index 2e8b2b67..eb8442c2 100644 --- a/cds/container/split_list_map.h +++ b/cds/container/split_list_map.h @@ -141,45 +141,12 @@ namespace cds { namespace container { //@cond typedef typename base_class::maker::type_traits::key_accessor key_accessor; typedef typename base_class::node_type node_type; + //@endcond public: /// Guarded pointer typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_set > guarded_ptr; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class ensure_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_functor_wrapper() {} - ensure_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( bool bNew, value_type& item, const Q& /*val*/ ) - { - base_class::get()( bNew, item ); - } - }; - - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper() {} - find_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( value_type& pair, Q const& /*val*/ ) - { - base_class::get()( pair ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - public: /// Forward iterator (see SplitListSet::iterator) /** @@ -379,15 +346,10 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { //TODO: pass arguments by reference (make_pair makes copy) -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::ensure( std::make_pair( key, mapped_type() ), [&func](bool bNew, value_type& item, value_type const& /*val*/) { cds::unref(func)( bNew, item ); } ); -# else - ensure_functor_wrapper fw( func ); - return base_class::ensure( std::make_pair( key, mapped_type() ), cds::ref(fw) ); -# endif } /// Deletes \p key from the map @@ -520,12 +482,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } ); -# else - find_functor_wrapper fw(f); - return base_class::find( key, cds::ref(fw) ); -# endif } /// Finds the key \p val using \p pred predicate for searching @@ -538,14 +495,9 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper(), [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } ); -# else - find_functor_wrapper fw(f); - return base_class::find_with( key, cds::details::predicate_wrapper(), cds::ref(fw) ); -# endif } /// Finds the key \p key diff --git a/cds/container/split_list_map_rcu.h b/cds/container/split_list_map_rcu.h index b8bc6638..cc94b742 100644 --- a/cds/container/split_list_map_rcu.h +++ b/cds/container/split_list_map_rcu.h @@ -186,38 +186,6 @@ namespace cds { namespace container { protected: //@cond typedef typename base_class::maker::type_traits::key_accessor key_accessor; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class ensure_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - ensure_functor_wrapper() {} - ensure_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( bool bNew, value_type& item, const Q& /*val*/ ) - { - base_class::get()( bNew, item ); - } - }; - - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper() {} - find_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( value_type& pair, Q const& /*val*/ ) - { - base_class::get()( pair ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond public: @@ -425,15 +393,10 @@ namespace cds { namespace container { std::pair ensure( K const& key, Func func ) { //TODO: pass arguments by reference (make_pair makes copy) -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::ensure( std::make_pair( key, mapped_type() ), [&func](bool bNew, value_type& item, value_type const& /*val*/) { cds::unref(func)( bNew, item ); } ); -# else - ensure_functor_wrapper fw( func ); - return base_class::ensure( std::make_pair( key, mapped_type() ), cds::ref(fw) ); -# endif } /// Deletes \p key from the map @@ -581,12 +544,7 @@ namespace cds { namespace container { template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } ); -# else - find_functor_wrapper fw(f); - return base_class::find( key, cds::ref(fw) ); -# endif } /// Finds the key \p key using \p pred predicate for searching @@ -599,14 +557,9 @@ namespace cds { namespace container { template bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper(), [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } ); -# else - find_functor_wrapper fw(f); - return base_class::find_with( key, cds::details::predicate_wrapper(), cds::ref(fw) ); -# endif } /// Finds the key \p key diff --git a/cds/container/split_list_set.h b/cds/container/split_list_set.h index cfbe04bd..ebbf6a0b 100644 --- a/cds/container/split_list_set.h +++ b/cds/container/split_list_set.h @@ -172,24 +172,14 @@ namespace cds { namespace container { template bool find_( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } ); -# else - find_functor_wrapper fw(f); - return base_class::find( val, cds::ref(fw) ); -# endif } template bool find_with_( Q& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, typename maker::template predicate_wrapper::type(), [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } ); -# else - find_functor_wrapper fw(f); - return base_class::find_with( val, typename maker::template predicate_wrapper::type(), cds::ref(fw) ); -# endif } template @@ -226,65 +216,6 @@ namespace cds { namespace container { //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor_wrapper( Func f ): base_class(f) {} - - void operator()(node_type& node) - { - base_class::get()( node.m_Value ); - } - }; - - template - class ensure_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - Q const& m_val; - public: - ensure_functor_wrapper( Func f, Q const& v ): base_class(f), m_val(v) {} - - void operator()( bool bNew, node_type& item, node_type const& /*val*/ ) - { - base_class::get()( bNew, item.m_Value, m_val ); - } - }; - - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; - - template - class erase_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - erase_functor_wrapper( Func f ): base_class( f ) {} - - void operator()(node_type& node) - { - base_class::get()( node.m_Value ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond - protected: /// Forward iterator /** @@ -468,13 +399,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) -# else - insert_functor_wrapper fw(f); - if ( base_class::insert( *pNode, cds::ref(fw) ) ) -# endif - { + if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) { pNode.release(); return true; } @@ -527,15 +452,10 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRet = base_class::ensure( *pNode, [&func, &val]( bool bNew, node_type& item, node_type const& /*val*/ ) { cds::unref(func)( bNew, item.m_Value, val ); } ); -# else - ensure_functor_wrapper fw( func, val ); - std::pair bRet = base_class::ensure( *pNode, cds::ref(fw) ); -# endif if ( bRet.first && bRet.second ) pNode.release(); @@ -593,12 +513,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f](node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor_wrapper fw( f ); - return base_class::erase( key, cds::ref(fw) ); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -611,13 +526,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, typename maker::template predicate_wrapper::type(), [&f](node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor_wrapper fw( f ); - return base_class::erase_with( key, typename maker::template predicate_wrapper::type(), cds::ref(fw) ); -# endif } /// Extracts the item with specified \p key diff --git a/cds/container/split_list_set_nogc.h b/cds/container/split_list_set_nogc.h index 11a90ed1..833e728f 100644 --- a/cds/container/split_list_set_nogc.h +++ b/cds/container/split_list_set_nogc.h @@ -81,21 +81,8 @@ namespace cds { namespace container { } }; typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr; - //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_ensure_functor - { - void operator()( bool /*bNew*/, node_type& /*item*/, node_type& /*val*/ ) - {} - }; -# endif - //@endcond - - public: /// Initialize split-ordered list of default capacity /** @@ -292,11 +279,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair ret = base_class::ensure_( *pNode, [](bool /*bNew*/, node_type& /*item*/, node_type& /*val*/){} ); -# else - std::pair ret = base_class::ensure_( *pNode, empty_ensure_functor() ); -# endif if ( ret.first != base_class::end() && ret.second ) { pNode.release(); return std::make_pair( iterator(ret.first), ret.second ); diff --git a/cds/container/split_list_set_rcu.h b/cds/container/split_list_set_rcu.h index 44475642..43101c4d 100644 --- a/cds/container/split_list_set_rcu.h +++ b/cds/container/split_list_set_rcu.h @@ -217,24 +217,14 @@ namespace cds { namespace container { template bool find_( Q& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( val, [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } ); -# else - find_functor_wrapper fw(f); - return base_class::find( val, cds::ref(fw) ); -# endif } template bool find_with_( Q& val, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( val, typename maker::template predicate_wrapper::type(), [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } ); -# else - find_functor_wrapper fw(f); - return base_class::find_with( val, typename maker::template predicate_wrapper::type(), cds::ref(fw) ); -# endif } @@ -269,73 +259,6 @@ namespace cds { namespace container { return false; } - - //@endcond - - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class insert_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - insert_functor_wrapper( Func f ): base_class(f) {} - - void operator()(node_type& node) - { - base_class::get()( node.m_Value ); - } - }; - - template - class ensure_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - Q const& m_val; - public: - ensure_functor_wrapper( Func f, Q const& v ): base_class(f), m_val(v) {} - - void operator()( bool bNew, node_type& item, node_type const& /*val*/ ) - { - base_class::get()( bNew, item.m_Value, m_val ); - } - }; - - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( node_type& item, Q& val ) - { - base_class::get()( item.m_Value, val ); - } - }; - - struct empty_find_functor - { - template - void operator()( node_type&, Q& ) - {} - }; - - template - class erase_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - erase_functor_wrapper( Func f ): base_class( f ) {} - - void operator()(node_type& node) - { - base_class::get()( node.m_Value ); - } - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT //@endcond protected: @@ -522,13 +445,7 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) -# else - insert_functor_wrapper fw(f); - if ( base_class::insert( *pNode, cds::ref(fw) ) ) -# endif - { + if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) { pNode.release(); return true; } @@ -585,16 +502,10 @@ namespace cds { namespace container { { scoped_node_ptr pNode( alloc_node( val )); -# ifdef CDS_CXX11_LAMBDA_SUPPORT std::pair bRet = base_class::ensure( *pNode, [&func, &val]( bool bNew, node_type& item, node_type const& /*val*/ ) { cds::unref(func)( bNew, item.m_Value, val ); } ); -# else - ensure_functor_wrapper fw( func, val ); - std::pair bRet = base_class::ensure( *pNode, cds::ref(fw) ); -# endif - if ( bRet.first && bRet.second ) pNode.release(); return bRet; @@ -657,12 +568,7 @@ namespace cds { namespace container { template bool erase( Q const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase( key, [&f](node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor_wrapper fw( f ); - return base_class::erase( key, cds::ref(fw) ); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -675,13 +581,8 @@ namespace cds { namespace container { template bool erase_with( Q const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::erase_with( key, typename maker::template predicate_wrapper::type(), [&f](node_type& node) { cds::unref(f)( node.m_Value ); } ); -# else - erase_functor_wrapper fw( f ); - return base_class::erase_with( key, typename maker::template predicate_wrapper::type(), cds::ref(fw) ); -# endif } /// Extracts an item from the set diff --git a/cds/container/striped_map.h b/cds/container/striped_map.h index fd77756c..892225cb 100644 --- a/cds/container/striped_map.h +++ b/cds/container/striped_map.h @@ -8,10 +8,6 @@ #include #include -#ifndef CDS_CXX11_LAMBDA_SUPPORT -# include -#endif - namespace cds { namespace container { //@cond @@ -537,46 +533,6 @@ template return p.first; } }; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper() {} - find_functor_wrapper( Func f ): base_class(f) {} - - template - void operator()( value_type& pair, Q const& /*val*/ ) - { - base_class::get()( pair ); - } - }; - - template - class insert_value_functor - { - Q const& m_val; - public: - insert_value_functor( Q const & v) - : m_val(v) - {} - - void operator()( value_type& item ) - { - item.second = m_val; - } - }; - - struct dummy_insert_functor - { - void operator()( value_type& item ) - {} - }; -# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond public: @@ -631,11 +587,7 @@ template template bool insert( K const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [](value_type&){} ); -# else - return insert_key( key, dummy_insert_functor() ); -# endif } /// Inserts new node @@ -652,12 +604,7 @@ template template bool insert( K const& key, V const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert_key( key, [&val](value_type& item) { item.second = val ; } ); -# else - insert_value_functor f(val); - return insert_key( key, cds::ref(f) ); -# endif } /// Inserts new node and initialize it by a functor @@ -796,11 +743,7 @@ template ,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_erase_with >::type > bool erase_with( K const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_with( key, pred, [](value_type const&) {} ); -# else - return erase_with( key, pred, typename base_class::empty_erase_functor() ); -# endif } /// Delete \p key from the map @@ -866,12 +809,7 @@ template template bool find( K const& key, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find( key, [&f]( value_type& pair, K const& ) mutable { cds::unref(f)(pair); } ); -# else - find_functor_wrapper fw(f); - return base_class::find( key, cds::ref(fw) ); -# endif } /// Find the key \p val using \p pred predicate @@ -889,13 +827,8 @@ template ,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_find_with >::type > bool find_with( K const& key, Less pred, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return base_class::find_with( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >(), [&f]( value_type& pair, K const& ) mutable { cds::unref(f)(pair); } ); -# else - find_functor_wrapper fw(f); - return base_class::find_with( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >(), cds::ref(fw) ); -# endif } /// Find the key \p key diff --git a/cds/container/striped_set.h b/cds/container/striped_set.h index b51e7ccf..8c82d5be 100644 --- a/cds/container/striped_set.h +++ b/cds/container/striped_set.h @@ -517,27 +517,6 @@ namespace cds { namespace container { typedef typename base_class::scoped_resize_lock scoped_resize_lock; //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; -# endif - //@endcond - public: /// Default ctor. The initial capacity is 16. StripedSet() @@ -590,11 +569,7 @@ namespace cds { namespace container { template bool insert( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -718,11 +693,7 @@ namespace cds { namespace container { template bool erase( Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase( key, [](value_type const&) {} ); -# else - return erase( key, empty_erase_functor() ); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -740,11 +711,7 @@ namespace cds { namespace container { ,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_erase_with >::type > bool erase_with( Q const& key, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_with( key, pred, [](value_type const&) {} ); -# else - return erase_with( key, pred, empty_erase_functor() ); -# endif } /// Delete \p key from the set diff --git a/cds/container/vyukov_mpmc_cycle_queue.h b/cds/container/vyukov_mpmc_cycle_queue.h index 051f05b9..9e0234e4 100644 --- a/cds/container/vyukov_mpmc_cycle_queue.h +++ b/cds/container/vyukov_mpmc_cycle_queue.h @@ -108,15 +108,6 @@ namespace cds { namespace container { {} }; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct copy_construct { - void operator()( value_type& dest, value_type const& src ) - { - new ( &dest ) value_type( src ); - } - }; -# endif - typedef cds::details::trivial_assign< value_type, value_type > copy_assign; typedef typename options::buffer::template rebind::other buffer; @@ -214,11 +205,7 @@ namespace cds { namespace container { /// @anchor cds_container_VyukovMPMCCycleQueue_enqueue Enqueues \p data to queue bool enqueue(value_type const& data ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return enqueue( data, [](value_type& dest, value_type const& src){ new ( &dest ) value_type( src ); }); -# else - return enqueue( data, copy_construct() ); -# endif } /// Enqueues data of type \ref cds_container_VyukovMPMCCycleQueue_value_type "value_type" constructed with std::forward(args)... diff --git a/cds/intrusive/cuckoo_set.h b/cds/intrusive/cuckoo_set.h index 15924713..790a7852 100644 --- a/cds/intrusive/cuckoo_set.h +++ b/cds/intrusive/cuckoo_set.h @@ -1904,39 +1904,6 @@ namespace cds { namespace intrusive { typedef size_t hash_array[c_nArity] ; ///< hash array -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; -# endif - -# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || ((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL ) && _MSC_VER == 1600) - template - class disposer_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - disposer_wrapper( Disposer d): base_class(d) {} - - void operator()( node_type * pNode ) - { - base_class::get()( node_traits::to_value_ptr( pNode )); - } - }; -# endif - struct position { bucket_iterator itPrev; bucket_iterator itFound; @@ -2383,11 +2350,7 @@ namespace cds { namespace intrusive { */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -2601,11 +2564,7 @@ namespace cds { namespace intrusive { template value_type * erase( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase( val, [](value_type const&) {} ); -# else - return erase( val, empty_erase_functor() ); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -2619,11 +2578,7 @@ namespace cds { namespace intrusive { template value_type * erase_with( Q const& val, Predicate pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, typename predicate_wrapper::type(), [](value_type const&) {} ); -# else - return erase_( val, typename predicate_wrapper::type(), empty_erase_functor() ); -# endif } /// Delete the item from the set @@ -2757,11 +2712,7 @@ namespace cds { namespace intrusive { template bool find( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find( val, [](value_type&, Q const& ) {} ); -# else - return find( val, empty_find_functor() ); -# endif } /// Find the key \p val using \p pred predicate for comparing @@ -2775,11 +2726,7 @@ namespace cds { namespace intrusive { template bool find_with( Q const& val, Predicate pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with( val, typename predicate_wrapper::type(), [](value_type& , Q const& ) {} ); -# else - return find_with( val, typename predicate_wrapper::type(), empty_find_functor() ); -# endif } /// Clears the set @@ -2810,19 +2757,11 @@ namespace cds { namespace intrusive { // locks entire array scoped_full_lock sl( m_MutexPolicy ); -# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || ((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL ) && _MSC_VER == 1600) - disposer_wrapper disp( oDisposer ); -# endif for ( unsigned int i = 0; i < c_nArity; ++i ) { bucket_entry * pEntry = m_BucketTable[i]; bucket_entry * pEnd = pEntry + m_nBucketMask + 1; for ( ; pEntry != pEnd ; ++pEntry ) { -# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER == 1600) - // MSVC 10: error to call nested typedefs node_traits from lambda pEntry->clear( [&oDisposer]( node_type * pNode ){ oDisposer( node_traits::to_value_ptr( pNode )) ; } ); -# else - pEntry->clear( cds::ref(disp) ); -# endif } } m_ItemCounter.reset(); diff --git a/cds/intrusive/ellen_bintree_impl.h b/cds/intrusive/ellen_bintree_impl.h index d8e6c0dd..63f0cc4c 100644 --- a/cds/intrusive/ellen_bintree_impl.h +++ b/cds/intrusive/ellen_bintree_impl.h @@ -318,53 +318,6 @@ namespace cds { namespace intrusive { m_Root.m_pLeft.store( &m_LeafInf1, memory_model::memory_order_relaxed ); m_Root.m_pRight.store( &m_LeafInf2, memory_model::memory_order_release ); } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct trivial_equal_functor { - template - bool operator()( Q const& , leaf_node const& ) const - { - return true; - } - }; - - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct assign_guard_functor { - typename gc::Guard& m_guard; - assign_guard_functor( typename gc::Guard& guard ) - : m_guard(guard) - {} - - template - void operator()( value_type& val, Q& ) - { - m_guard.assign( &val ); - } - - void operator()( value_type& val ) - { - m_guard.assign( &val ); - } - }; - -# endif - -# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || (CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10) - struct unlink_equal_functor { - bool operator()( value_type const& v, leaf_node const& n ) const - { - return &v == node_traits::to_value_ptr( n ); - } - }; - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; -# endif //@endcond public: @@ -390,11 +343,7 @@ namespace cds { namespace intrusive { */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -532,14 +481,9 @@ namespace cds { namespace intrusive { */ bool unlink( value_type& val ) { -# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10) - // vc10 generates an error for the lambda - it sees cds::intrusive::node_traits but not class-defined node_traits return erase_( val, node_compare(), []( value_type const& v, leaf_node const& n ) -> bool { return &v == node_traits::to_value_ptr( n ); }, [](value_type const&) {} ); -# else - return erase_( val, node_compare(), unlink_equal_functor(), empty_erase_functor() ); -# endif } /// Deletes the item from the tree @@ -553,13 +497,9 @@ namespace cds { namespace intrusive { template bool erase( const Q& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, node_compare(), []( Q const&, leaf_node const& ) -> bool { return true; }, [](value_type const&) {} ); -# else - return erase_( val, node_compare(), trivial_equal_functor(), empty_erase_functor() ); -# endif } /// Delete the item from the tree with comparing functor \p pred @@ -580,13 +520,9 @@ namespace cds { namespace intrusive { node_traits > compare_functor; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, compare_functor(), []( Q const&, leaf_node const& ) -> bool { return true; }, [](value_type const&) {} ); -# else - return erase_( val, compare_functor(), trivial_equal_functor(), empty_erase_functor() ); -# endif } /// Deletes the item from the tree @@ -611,13 +547,9 @@ namespace cds { namespace intrusive { template bool erase( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, node_compare(), []( Q const&, leaf_node const& ) -> bool { return true; }, f ); -# else - return erase_( val, node_compare(), trivial_equal_functor(), f ); -# endif } /// Delete the item from the tree with comparing functor \p pred @@ -638,13 +570,9 @@ namespace cds { namespace intrusive { node_traits > compare_functor; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, compare_functor(), []( Q const&, leaf_node const& ) -> bool { return true; }, f ); -# else - return erase_( val, compare_functor(), trivial_equal_functor(), f ); -# endif } /// Extracts an item with minimal key from the tree @@ -1444,14 +1372,9 @@ namespace cds { namespace intrusive { template bool extract_( typename gc::Guard& guard, Q const& key ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( key, node_compare(), []( Q const&, leaf_node const& ) -> bool { return true; }, [&guard]( value_type& found ) { guard.assign( &found ); } ); -# else - assign_guard_functor f( guard ); - return erase_( key, node_compare(), trivial_equal_functor(), cds::ref(f) ); -# endif } template @@ -1464,14 +1387,9 @@ namespace cds { namespace intrusive { node_traits > compare_functor; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( key, compare_functor(), []( Q const&, leaf_node const& ) -> bool { return true; }, [&guard]( value_type& found ) { guard.assign( &found ); } ); -# else - assign_guard_functor f( guard ); - return erase_( key, compare_functor(), trivial_equal_functor(), cds::ref(f) ); -# endif } bool extract_max_( typename gc::Guard& guard ) @@ -1612,23 +1530,13 @@ namespace cds { namespace intrusive { template bool get_( typename gc::Guard& guard, Q const& val ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_( val, [&guard]( value_type& found, Q const& ) { guard.assign( &found ); } ); -# else - assign_guard_functor f(guard); - return find_( val, cds::ref(f) ); -# endif } template bool get_with_( typename gc::Guard& guard, Q const& val, Less pred ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with_( val, pred, [&guard]( value_type& found, Q const& ) { guard.assign( &found ); } ); -# else - assign_guard_functor f(guard); - return find_with_( val, pred, cds::ref(f) ); -# endif } //@endcond diff --git a/cds/intrusive/ellen_bintree_rcu.h b/cds/intrusive/ellen_bintree_rcu.h index 9e608ca4..e7029da4 100644 --- a/cds/intrusive/ellen_bintree_rcu.h +++ b/cds/intrusive/ellen_bintree_rcu.h @@ -708,33 +708,6 @@ namespace cds { namespace intrusive { m_Root.m_pLeft.store( &m_LeafInf1, memory_model::memory_order_relaxed ); m_Root.m_pRight.store( &m_LeafInf2, memory_model::memory_order_release ); } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct trivial_equal_functor { - template - bool operator()( Q const& , leaf_node const& ) const - { - return true; - } - }; - - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; -# endif -# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || (CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10) - struct unlink_equal_functor { - bool operator()( value_type const& v, leaf_node const& n ) const - { - return &v == node_traits::to_value_ptr( n ); - } - }; - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; -# endif //@endcond public: @@ -762,11 +735,7 @@ namespace cds { namespace intrusive { */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -922,14 +891,9 @@ namespace cds { namespace intrusive { */ bool unlink( value_type& val ) { -# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10) - // vc10 generates an error for the lambda - it sees cds::intrusive::node_traits but not class-defined node_traits return erase_( val, node_compare(), []( value_type const& v, leaf_node const& n ) -> bool { return &v == node_traits::to_value_ptr( n ); }, [](value_type const&) {} ); -# else - return erase_( val, node_compare(), unlink_equal_functor(), empty_erase_functor() ); -# endif } /// Deletes the item from the tree @@ -945,13 +909,9 @@ namespace cds { namespace intrusive { template bool erase( const Q& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, node_compare(), []( Q const&, leaf_node const& ) -> bool { return true; }, [](value_type const&) {} ); -# else - return erase_( val, node_compare(), trivial_equal_functor(), empty_erase_functor() ); -# endif } /// Delete the item from the tree with comparing functor \p pred @@ -972,13 +932,9 @@ namespace cds { namespace intrusive { node_traits > compare_functor; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, compare_functor(), []( Q const&, leaf_node const& ) -> bool { return true; }, [](value_type const&) {} ); -# else - return erase_( val, compare_functor(), trivial_equal_functor(), empty_erase_functor() ); -# endif } /// Deletes the item from the tree @@ -1005,13 +961,9 @@ namespace cds { namespace intrusive { template bool erase( Q const& val, Func f ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, node_compare(), []( Q const&, leaf_node const& ) -> bool { return true; }, f ); -# else - return erase_( val, node_compare(), trivial_equal_functor(), f ); -# endif } /// Delete the item from the tree with comparing functor \p pred @@ -1032,13 +984,9 @@ namespace cds { namespace intrusive { node_traits > compare_functor; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, compare_functor(), []( Q const&, leaf_node const& ) -> bool { return true; }, f ); -# else - return erase_( val, compare_functor(), trivial_equal_functor(), f ); -# endif } /// Extracts an item with minimal key from the tree diff --git a/cds/intrusive/lazy_list_impl.h b/cds/intrusive/lazy_list_impl.h index e2181654..b8c4a73f 100644 --- a/cds/intrusive/lazy_list_impl.h +++ b/cds/intrusive/lazy_list_impl.h @@ -294,13 +294,6 @@ namespace cds { namespace intrusive { m_pos.unlock(); } }; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_erase_functor { - void operator()( value_type const & item ) - {} - }; -# endif //@endcond protected: @@ -1112,25 +1105,14 @@ namespace cds { namespace intrusive { bool erase_at( node_type * pHead, const Q& val, Compare cmp ) { position pos; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( pHead, val, cmp, [](value_type const &){}, pos ); -# else - return erase_at( pHead, val, cmp, empty_erase_functor(), pos ); -# endif } template bool extract_at( node_type * pHead, typename gc::Guard& gp, const Q& val, Compare cmp ) { position pos; - if ( -# ifdef CDS_CXX11_LAMBDA_SUPPORT - erase_at( pHead, val, cmp, [](value_type const &){}, pos ) -# else - erase_at( pHead, val, cmp, empty_erase_functor(), pos ) -# endif - ) - { + if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) { gp.assign( pos.guards.template get(position::guard_current_item) ); return true; } diff --git a/cds/intrusive/lazy_list_rcu.h b/cds/intrusive/lazy_list_rcu.h index 9761bfde..21adc8be 100644 --- a/cds/intrusive/lazy_list_rcu.h +++ b/cds/intrusive/lazy_list_rcu.h @@ -182,28 +182,6 @@ namespace cds { namespace intrusive { }; typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_erase_functor { - void operator()( value_type const& item ) - {} - }; - - struct get_functor { - value_type * pFound; - - get_functor() - : pFound( nullptr ) - {} - - template - void operator()( value_type& item, Q& val ) - { - pFound = &item; - } - }; -# endif - //@endcond protected: @@ -1084,11 +1062,7 @@ namespace cds { namespace intrusive { bool erase_at( node_type * pHead, Q const& val, Compare cmp ) { position pos; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( pHead, val, cmp, [](value_type const &){}, pos ); -# else - return erase_at( pHead, val, cmp, empty_erase_functor(), pos ); -# endif } template @@ -1169,14 +1143,9 @@ namespace cds { namespace intrusive { template value_type * get_at( node_type * pHead, Q const& val, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT value_type * pFound = nullptr; return find_at( pHead, val, cmp, [&pFound](value_type& found, Q const& ) { pFound = &found; } ) ? pFound : nullptr; -# else - get_functor gf; - return find_at( pHead, val, cmp, cds::ref( gf ) ) ? gf.pFound : nullptr; -# endif } //@endcond diff --git a/cds/intrusive/michael_list_impl.h b/cds/intrusive/michael_list_impl.h index 83160c5f..fa8e1cb0 100644 --- a/cds/intrusive/michael_list_impl.h +++ b/cds/intrusive/michael_list_impl.h @@ -239,13 +239,6 @@ namespace cds { namespace intrusive { }; }; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_erase_functor { - void operator()( value_type const & item ) - {} - }; -# endif - struct clean_disposer { void operator()( value_type * p ) { @@ -1043,11 +1036,7 @@ namespace cds { namespace intrusive { bool erase_at( atomic_node_ptr& refHead, Q const& val, Compare cmp ) { position pos; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( refHead, val, cmp, [](value_type const&){}, pos ); -# else - return erase_at( refHead, val, cmp, empty_erase_functor(), pos ); -# endif } template diff --git a/cds/intrusive/michael_list_rcu.h b/cds/intrusive/michael_list_rcu.h index adb13514..96e7f191 100644 --- a/cds/intrusive/michael_list_rcu.h +++ b/cds/intrusive/michael_list_rcu.h @@ -107,28 +107,6 @@ namespace cds { namespace intrusive { typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_erase_functor { - void operator()( value_type const & item ) - {} - }; - - struct get_functor { - value_type * pFound; - - get_functor() - : pFound( nullptr ) - {} - - template - void operator()( value_type& item, Q& val ) - { - pFound = &item; - } - }; - -# endif - static void clear_links( node_type * pNode ) { pNode->m_pNext.store( marked_node_ptr(), memory_model::memory_order_relaxed ); @@ -940,11 +918,7 @@ namespace cds { namespace intrusive { bool erase_at( atomic_node_ptr& refHead, const Q& val, Compare cmp ) { position pos; -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_at( refHead, val, cmp, [](value_type const&){}, pos ); -# else - return erase_at( refHead, val, cmp, empty_erase_functor(), pos ); -# endif } template @@ -991,16 +965,10 @@ namespace cds { namespace intrusive { template value_type * get_at( atomic_node_ptr& refHead, Q const& val, Compare cmp ) const { -# ifdef CDS_CXX11_LAMBDA_SUPPORT value_type * pFound = nullptr; return find_at( refHead, val, cmp, [&pFound](value_type& found, Q const& ) { pFound = &found; } ) ? pFound : nullptr; -# else - get_functor gf; - return find_at( refHead, val, cmp, cds::ref(gf) ) - ? gf.pFound : nullptr; -# endif } template diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index 0f29612a..d0a8d854 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -204,17 +204,6 @@ namespace cds { namespace intrusive { }; //@endcond - protected: - //@cond -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_cleaner - { - void operator()( value_type const& ) const - {} - }; -# endif - //@endcond - public: typedef typename traits::buffer::template rebind::other buffer_type ; ///< Heap array buffer type @@ -341,11 +330,7 @@ namespace cds { namespace intrusive { */ void clear() { -# ifdef CDS_CXX11_LAMBDA_SUPPORT clear_with( []( value_type const& src ) {} ); -# else - clear_with( empty_cleaner() ); -# endif } /// Clears the queue (not atomic) diff --git a/cds/intrusive/skip_list_impl.h b/cds/intrusive/skip_list_impl.h index b58ba19c..91e2acd4 100644 --- a/cds/intrusive/skip_list_impl.h +++ b/cds/intrusive/skip_list_impl.h @@ -417,63 +417,6 @@ namespace cds { namespace intrusive { node_type * pCur ; // guarded by guards; needed only for *ensure* function }; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; - - struct get_functor { - typename gc::Guard& m_guard; - - get_functor( typename gc::Guard& gp ) - : m_guard(gp) - {} - - template - void operator()( value_type& item, Q& val ) - { - m_guard.assign( &item ); - } - }; - - template - struct insert_at_ensure_functor { - Func m_func; - insert_at_ensure_functor( Func f ) : m_func(f) {} - - void operator()( value_type& item ) - { - cds::unref( m_func)( true, item, item ); - } - }; - - struct copy_value_functor { - template - void operator()( Q& dest, value_type const& src ) const - { - dest = src; - } - }; - - struct dummy_copy_functor { - template - void operator()( Q&, value_type const&) const {} - }; -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond protected: @@ -895,12 +838,7 @@ namespace cds { namespace intrusive { template bool get_with_( typename gc::Guard& guard, Q const& val, Compare cmp ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with_( val, cmp, [&guard](value_type& found, Q const& ) { guard.assign(&found); } ); -# else - get_functor gf(guard); - return find_with_( val, cmp, cds::ref(gf) ); -# endif } template @@ -946,14 +884,7 @@ namespace cds { namespace intrusive { assert( cmp( *node_traits::to_value_ptr( pDel ), val ) == 0 ); unsigned int nHeight = pDel->height(); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {} )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractSuccess(); @@ -980,14 +911,7 @@ namespace cds { namespace intrusive { unsigned int nHeight = pDel->height(); gDel.assign( node_traits::to_value_ptr(pDel) ); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {} )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractMinSuccess(); @@ -1014,14 +938,7 @@ namespace cds { namespace intrusive { unsigned int nHeight = pDel->height(); gDel.assign( node_traits::to_value_ptr(pDel) ); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {} )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractMaxSuccess(); @@ -1117,11 +1034,7 @@ namespace cds { namespace intrusive { */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -1226,10 +1139,6 @@ namespace cds { namespace intrusive { bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr; bool bTowerMade = false; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - insert_at_ensure_functor wrapper( func ); -# endif - position pos; while ( true ) { @@ -1251,12 +1160,7 @@ namespace cds { namespace intrusive { bTowerOk = true; } -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) -# else - if ( !insert_at_position( val, pNode, pos, cds::ref(wrapper) )) -# endif - { + if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) { m_Stat.onInsertRetry(); continue; } @@ -1301,14 +1205,7 @@ namespace cds { namespace intrusive { typename gc::Guard gDel; gDel.assign( node_traits::to_value_ptr(pDel) ); - if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - )) - { + if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {} )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onUnlinkSuccess(); @@ -1449,11 +1346,7 @@ namespace cds { namespace intrusive { template bool erase( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, key_comparator(), [](value_type const&) {} ); -# else - return erase_( val, key_comparator(), empty_erase_functor() ); -# endif } /// Deletes the item from the set with comparing functor \p pred @@ -1468,11 +1361,7 @@ namespace cds { namespace intrusive { template bool erase_with( Q const& val, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_( val, cds::opt::details::make_comparator_from_less(), [](value_type const&) {} ); -# else - return erase_( val, cds::opt::details::make_comparator_from_less(), empty_erase_functor() ); -# endif } /// Deletes the item from the set @@ -1616,11 +1505,7 @@ namespace cds { namespace intrusive { template bool find( Q const & val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with_( val, key_comparator(), [](value_type& , Q const& ) {} ); -# else - return find_with_( val, key_comparator(), empty_find_functor() ); -# endif } /// Finds the key \p val with comparing functor \p pred @@ -1634,11 +1519,7 @@ namespace cds { namespace intrusive { template bool find_with( Q const& val, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with_( val, cds::opt::details::make_comparator_from_less(), [](value_type& , Q const& ) {} ); -# else - return find_with_( val, cds::opt::details::make_comparator_from_less(), empty_find_functor() ); -# endif } /// Finds the key \p val and return the item found diff --git a/cds/intrusive/skip_list_nogc.h b/cds/intrusive/skip_list_nogc.h index 3062062b..5564479e 100644 --- a/cds/intrusive/skip_list_nogc.h +++ b/cds/intrusive/skip_list_nogc.h @@ -410,31 +410,6 @@ namespace cds { namespace intrusive { node_type * pCur; }; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; - - template - struct insert_at_ensure_functor { - Func m_func; - insert_at_ensure_functor( Func f ) : m_func(f) {} - - void operator()( value_type& item ) - { - cds::unref( m_func)( true, item, item ); - } - }; - -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - class head_node: public node_type { typename node_type::atomic_ptr m_Tower[c_nMaxHeight]; @@ -714,12 +689,7 @@ namespace cds { namespace intrusive { bTowerOk = true; } -# ifndef CDS_CXX11_LAMBDA_SUPPORT - if ( !insert_at_position( val, pNode, pos, empty_insert_functor() )) -# else - if ( !insert_at_position( val, pNode, pos, []( value_type& ) {} )) -# endif - { + if ( !insert_at_position( val, pNode, pos, []( value_type& ) {} )) { m_Stat.onInsertRetry(); continue; } @@ -768,10 +738,6 @@ namespace cds { namespace intrusive { bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr; bool bTowerMade = false; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - insert_at_ensure_functor wrapper( func ); -# endif - position pos; while ( true ) { @@ -793,12 +759,7 @@ namespace cds { namespace intrusive { bTowerOk = true; } -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) -# else - if ( !insert_at_position( val, pNode, pos, cds::ref(wrapper) )) -# endif - { + if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) { m_Stat.onInsertRetry(); continue; } @@ -910,12 +871,7 @@ namespace cds { namespace intrusive { template value_type * find( Q const& val ) const { - node_type * pNode = -# ifdef CDS_CXX11_LAMBDA_SUPPORT - find_with_( val, key_comparator(), [](value_type& , Q const& ) {} ); -# else - find_with_( val, key_comparator(), empty_find_functor() ); -# endif + node_type * pNode = find_with_( val, key_comparator(), [](value_type& , Q const& ) {} ); if ( pNode ) return node_traits::to_value_ptr( pNode ); return nullptr; @@ -931,12 +887,7 @@ namespace cds { namespace intrusive { template value_type * find_with( Q const& val, Less pred ) const { - node_type * pNode = -# ifdef CDS_CXX11_LAMBDA_SUPPORT - find_with_( val, cds::opt::details::make_comparator_from_less(), [](value_type& , Q const& ) {} ); -# else - find_with_( val, cds::opt::details::make_comparator_from_less(), empty_find_functor() ); -# endif + node_type * pNode = find_with_( val, cds::opt::details::make_comparator_from_less(), [](value_type& , Q const& ) {} ); if ( pNode ) return node_traits::to_value_ptr( pNode ); return nullptr; diff --git a/cds/intrusive/skip_list_rcu.h b/cds/intrusive/skip_list_rcu.h index da58a7ea..9d74a974 100644 --- a/cds/intrusive/skip_list_rcu.h +++ b/cds/intrusive/skip_list_rcu.h @@ -597,55 +597,6 @@ namespace cds { namespace intrusive { }; typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; - - struct get_functor { - value_type * pFound; - - template - void operator()( value_type& item, Q& val ) - { - pFound = &item; - } - }; - - template - struct insert_at_ensure_functor { - Func m_func; - insert_at_ensure_functor( Func f ) : m_func(f) {} - - void operator()( value_type& item ) - { - cds::unref( m_func)( true, item, item ); - } - }; - - struct copy_value_functor { - template - void operator()( Q& dest, value_type const& src ) const - { - dest = src; - } - }; - -# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT - //@endcond protected: @@ -1194,14 +1145,7 @@ retry: unsigned int const nHeight = pDel->height(); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - , true )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractSuccess(); @@ -1267,14 +1211,7 @@ retry: pDel = pos.pCur; unsigned int const nHeight = pDel->height(); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - , true )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractMinSuccess(); @@ -1322,14 +1259,7 @@ retry: pDel = pos.pCur; unsigned int const nHeight = pDel->height(); - if ( try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - , true )) - { + if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onExtractMaxSuccess(); @@ -1521,11 +1451,7 @@ retry: */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -1648,10 +1574,6 @@ retry: bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr; bool bTowerMade = false; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - insert_at_ensure_functor wrapper( func ); -# endif - rcu_lock rcuLock; while ( true ) { @@ -1673,12 +1595,7 @@ retry: bTowerOk = true; } -# ifdef CDS_CXX11_LAMBDA_SUPPORT - if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) -# else - if ( !insert_at_position( val, pNode, pos, cds::ref(wrapper) )) -# endif - { + if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) { m_Stat.onInsertRetry(); continue; } @@ -1735,14 +1652,7 @@ retry: unsigned int nHeight = pDel->height(); - if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type const&) {} -# else - empty_erase_functor() -# endif - , false )) - { + if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {}, false )) { --m_ItemCounter; m_Stat.onRemoveNode( nHeight ); m_Stat.onUnlinkSuccess(); @@ -1892,11 +1802,7 @@ retry: template bool erase( const Q& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return do_erase( val, key_comparator(), [](value_type const&) {} ); -# else - return do_erase( val, key_comparator(), empty_erase_functor() ); -# endif } /// Delete the item from the set with comparing functor \p pred @@ -1909,11 +1815,7 @@ retry: template bool erase_with( const Q& val, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return do_erase( val, cds::opt::details::make_comparator_from_less(), [](value_type const&) {} ); -# else - return do_erase( val, cds::opt::details::make_comparator_from_less(), empty_erase_functor() ); -# endif } /// Deletes the item from the set @@ -2051,11 +1953,7 @@ retry: template bool find( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return do_find_with( val, key_comparator(), [](value_type& , Q const& ) {} ); -# else - return do_find_with( val, key_comparator(), empty_find_functor() ); -# endif } /// Finds the key \p val with comparing functor \p pred @@ -2068,13 +1966,7 @@ retry: template bool find_with( Q const& val, Less pred ) { - return do_find_with( val, cds::opt::details::make_comparator_from_less(), -# ifdef CDS_CXX11_LAMBDA_SUPPORT - [](value_type& , Q const& ) {} -# else - empty_find_functor() -# endif - ); + return do_find_with( val, cds::opt::details::make_comparator_from_less(), [](value_type& , Q const& ) {} ); } /// Finds the key \p val and return the item found @@ -2112,15 +2004,9 @@ retry: { assert( gc::is_locked()); -# ifdef CDS_CXX11_LAMBDA_SUPPORT value_type * pFound; return do_find_with( val, key_comparator(), [&pFound](value_type& found, Q const& ) { pFound = &found; } ) ? pFound : nullptr; -# else - get_functor gf; - return do_find_with( val, key_comparator(), cds::ref(gf) ) - ? gf.pFound : nullptr; -# endif } /// Finds the key \p val and return the item found @@ -2137,16 +2023,10 @@ retry: { assert( gc::is_locked()); -# ifdef CDS_CXX11_LAMBDA_SUPPORT value_type * pFound; return do_find_with( val, cds::opt::details::make_comparator_from_less(), [&pFound](value_type& found, Q const& ) { pFound = &found; } ) ? pFound : nullptr; -# else - get_functor gf; - return do_find_with( val, cds::opt::details::make_comparator_from_less(), cds::ref(gf) ) - ? gf.pFound : nullptr; -# endif } /// Returns item count in the set diff --git a/cds/intrusive/split_list.h b/cds/intrusive/split_list.h index 790b5ecb..be144f84 100644 --- a/cds/intrusive/split_list.h +++ b/cds/intrusive/split_list.h @@ -464,13 +464,8 @@ namespace cds { namespace intrusive { dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT return m_List.find_at( pHead, sv, cmp, [&f](value_type& item, split_list::details::search_value_type& val){ cds::unref(f)(item, val.val ); }); -# else - split_list::details::find_functor_wrapper ffw( f ); - return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) ); -# endif } template diff --git a/cds/intrusive/split_list_base.h b/cds/intrusive/split_list_base.h index 9c1743a5..c8c99ed3 100644 --- a/cds/intrusive/split_list_base.h +++ b/cds/intrusive/split_list_base.h @@ -573,24 +573,6 @@ namespace cds { namespace intrusive { */ }; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - template - class find_functor_wrapper: protected cds::details::functor_wrapper - { - typedef cds::details::functor_wrapper base_class; - public: - find_functor_wrapper( Func f ) - : base_class( f ) - {} - - template - void operator()( ValueType& item, split_list::details::search_value_type& val ) - { - base_class::get()( item, val.val ); - } - }; -# endif - template class rebind_list_options { diff --git a/cds/intrusive/split_list_nogc.h b/cds/intrusive/split_list_nogc.h index f5f585dd..6195115f 100644 --- a/cds/intrusive/split_list_nogc.h +++ b/cds/intrusive/split_list_nogc.h @@ -607,13 +607,8 @@ namespace cds { namespace intrusive { split_list::details::search_value_type sv( val, split_list::regular_hash( nHash )); dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT return m_List.find_at( pHead, sv, cmp, [&f](value_type& item, split_list::details::search_value_type& val){ cds::unref(f)(item, val.val ); }); -# else - split_list::details::find_functor_wrapper ffw( f ); - return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) ); -# endif } //@endcond diff --git a/cds/intrusive/split_list_rcu.h b/cds/intrusive/split_list_rcu.h index 4eeb2b0c..8951f826 100644 --- a/cds/intrusive/split_list_rcu.h +++ b/cds/intrusive/split_list_rcu.h @@ -353,13 +353,8 @@ namespace cds { namespace intrusive { dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT return m_List.find_at( pHead, sv, cmp, [&f](value_type& item, split_list::details::search_value_type& val){ cds::unref(f)(item, val.val ); }); -# else - split_list::details::find_functor_wrapper ffw( f ); - return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) ); -# endif } template diff --git a/cds/intrusive/striped_set.h b/cds/intrusive/striped_set.h index 0e43f231..f038f311 100644 --- a/cds/intrusive/striped_set.h +++ b/cds/intrusive/striped_set.h @@ -305,24 +305,6 @@ namespace cds { namespace intrusive { typedef typename mutex_policy::scoped_cell_lock scoped_cell_lock; typedef typename mutex_policy::scoped_full_lock scoped_full_lock; typedef typename mutex_policy::scoped_resize_lock scoped_resize_lock; - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; - - struct empty_erase_functor { - void operator()( value_type const& ) - {} - }; - - struct empty_find_functor { - template - void operator()( value_type& item, Q& val ) - {} - }; -# endif //@endcond protected: @@ -489,11 +471,7 @@ namespace cds { namespace intrusive { */ bool insert( value_type& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return insert( val, []( value_type& ) {} ); -# else - return insert( val, empty_insert_functor() ); -# endif } /// Inserts new node @@ -611,11 +589,7 @@ namespace cds { namespace intrusive { template value_type * erase( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase( val, [](value_type const&) {} ); -# else - return erase( val, empty_erase_functor() ); -# endif } /// Deletes the item from the set using \p pred predicate for searching @@ -628,11 +602,7 @@ namespace cds { namespace intrusive { template value_type * erase_with( Q const& val, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return erase_with( val, pred, [](value_type const&) {} ); -# else - return erase_with( val, pred, empty_erase_functor() ); -# endif } /// Deletes the item from the set @@ -782,11 +752,7 @@ namespace cds { namespace intrusive { template bool find( Q const& val ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find( val, [](value_type&, Q const& ) {} ); -# else - return find( val, empty_find_functor() ); -# endif } /// Find the key \p val using \p pred predicate @@ -799,11 +765,7 @@ namespace cds { namespace intrusive { template bool find_with( Q const& val, Less pred ) { -# ifdef CDS_CXX11_LAMBDA_SUPPORT return find_with( val, pred, [](value_type& , Q const& ) {} ); -# else - return find_with( val, pred, empty_find_functor() ); -# endif } /// Clears the set diff --git a/cds/intrusive/striped_set/adapter.h b/cds/intrusive/striped_set/adapter.h index 5360cadb..8d95114b 100644 --- a/cds/intrusive/striped_set/adapter.h +++ b/cds/intrusive/striped_set/adapter.h @@ -206,13 +206,6 @@ namespace cds { namespace intrusive { typedef typename container_type::value_compare key_comparator; private: -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; -# endif - container_type m_Set; public: @@ -315,11 +308,7 @@ namespace cds { namespace intrusive { { value_type& val = *itWhat; from.base_container().erase( itWhat ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT insert( val, []( value_type& ) {} ); -# else - insert( val, empty_insert_functor() ); -# endif } }; } // namespace details diff --git a/cds/intrusive/striped_set/boost_list.h b/cds/intrusive/striped_set/boost_list.h index 54beb6af..1bda29ae 100644 --- a/cds/intrusive/striped_set/boost_list.h +++ b/cds/intrusive/striped_set/boost_list.h @@ -46,13 +46,6 @@ namespace cds { namespace intrusive { namespace striped_set { } }; -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; -# endif - template iterator find_key( Q const& key, Pred pred) { @@ -192,11 +185,7 @@ namespace cds { namespace intrusive { namespace striped_set { { value_type& val = *itWhat; from.base_container().erase( itWhat ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT insert( val, []( value_type& ) {} ); -# else - insert( val, empty_insert_functor() ); -# endif } }; diff --git a/cds/intrusive/striped_set/boost_slist.h b/cds/intrusive/striped_set/boost_slist.h index c42a763a..8edced68 100644 --- a/cds/intrusive/striped_set/boost_slist.h +++ b/cds/intrusive/striped_set/boost_slist.h @@ -83,14 +83,6 @@ namespace cds { namespace intrusive { namespace striped_set { return &val; } - -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; -# endif - private: container_type m_List; @@ -209,11 +201,7 @@ namespace cds { namespace intrusive { namespace striped_set { { value_type& val = *itWhat; from.base_container().erase( itWhat ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT insert( val, []( value_type& ) {} ); -# else - insert( val, empty_insert_functor() ); -# endif } }; diff --git a/cds/intrusive/striped_set/boost_unordered_set.h b/cds/intrusive/striped_set/boost_unordered_set.h index 24464cfc..f4a8fb3c 100644 --- a/cds/intrusive/striped_set/boost_unordered_set.h +++ b/cds/intrusive/striped_set/boost_unordered_set.h @@ -34,13 +34,6 @@ namespace cds { namespace intrusive { namespace striped_set { typedef cds::intrusive::striped_set::load_factor_resizing<256> default_resizing_policy; private: -# ifndef CDS_CXX11_LAMBDA_SUPPORT - struct empty_insert_functor { - void operator()( value_type& ) - {} - }; -# endif - template struct equal_from_compare { @@ -174,11 +167,7 @@ namespace cds { namespace intrusive { namespace striped_set { { value_type& val = *itWhat; from.base_container().erase( itWhat ); -# ifdef CDS_CXX11_LAMBDA_SUPPORT insert( val, []( value_type& ) {} ); -# else - insert( val, empty_insert_functor() ); -# endif } }; diff --git a/cds/intrusive/treiber_stack.h b/cds/intrusive/treiber_stack.h index 35c8a9bc..ba69873c 100644 --- a/cds/intrusive/treiber_stack.h +++ b/cds/intrusive/treiber_stack.h @@ -161,14 +161,6 @@ namespace cds { namespace intrusive { /// Operation descriptor used in elimination back-off typedef treiber_stack::operation< T > operation_desc; -# if !(defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)) - struct bkoff_predicate { - operation_desc * pOp; - bkoff_predicate( operation_desc * p ): pOp(p) {} - bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; } - }; -# endif - /// Elimination back-off data struct elimination_data { elimination_random_engine randEngine; ///< random engine @@ -243,19 +235,7 @@ namespace cds { namespace intrusive { } // Wait for colliding operation -# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10) - // MSVC++ 2010 compiler error C2065: 'op_busy' : undeclared identifier bkoff( [&op]() -> bool { return op.nStatus.load( atomics::memory_order_acquire ) != op_busy; } ); -# else - // Local structs is not supported by old compilers (for example, GCC 4.3) - //struct bkoff_predicate { - // operation_desc * pOp; - // bkoff_predicate( operation_desc * p ): pOp(p) {} - // bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; } - //}; - bkoff( bkoff_predicate(&op) ); -# endif - { slot_scoped_lock l( slot.lock ); if ( slot.pRec == myRec ) -- 2.34.1