X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=cds%2Fcontainer%2Fmichael_list_nogc.h;h=abae2284d09283d229c7b1e6e5bb4a474d5901ea;hb=58cd5ed861249381cdf697ef5b82a64e0f9e4ad3;hp=bd07cff4f81817102d1ee08673a355a86fbee788;hpb=7d15399a4d18ae2061ddb01656d85dbc940ff915;p=libcds.git diff --git a/cds/container/michael_list_nogc.h b/cds/container/michael_list_nogc.h index bd07cff4..abae2284 100644 --- a/cds/container/michael_list_nogc.h +++ b/cds/container/michael_list_nogc.h @@ -3,10 +3,10 @@ #ifndef __CDS_CONTAINER_MICHAEL_LIST_NOGC_H #define __CDS_CONTAINER_MICHAEL_LIST_NOGC_H -#include +#include +#include #include #include -#include namespace cds { namespace container { @@ -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( NULL ) - {} - - void operator ()(bool, node_type& item, node_type& ) - { - m_pItemFound = &item; - } - }; -# endif - //@endcond - protected: //@cond static node_type * alloc_node() @@ -106,13 +87,11 @@ namespace cds { namespace container { return cxx_allocator().New( v ); } -# ifdef CDS_EMPLACE_SUPPORT template static node_type * alloc_node( Args&&... args ) { return cxx_allocator().MoveNew( std::forward(args)... ); } -# endif static void free_node( node_type * pNode ) { @@ -174,7 +153,7 @@ namespace cds { namespace container { value_ptr operator ->() const { typename iterator_base::value_ptr p = iterator_base::operator ->(); - return p ? &(p->m_Value) : reinterpret_cast(NULL); + return p ? &(p->m_Value) : nullptr; } value_ref operator *() const @@ -233,7 +212,7 @@ namespace cds { namespace container { /// Returns an iterator that addresses the location succeeding the last element in a list /** Do not use the value returned by end function to access any item. - Internally, end returning value equals to NULL. + Internally, end returning value equals to \p nullptr. The returned value can be used only to control reaching the end of the list. For empty list \code begin() == end() \endcode @@ -323,20 +302,15 @@ namespace cds { namespace container { return std::make_pair( node_to_iterator( ret.first ), ret.second ); } -# ifdef CDS_EMPLACE_SUPPORT /// Inserts data of type \ref value_type constructed with std::forward(args)... /** Return an iterator pointing to inserted item if success \ref end() otherwise - - This function is available only for compiler that supports - variadic template and move semantics */ template iterator emplace( Args&&... args ) { return node_to_iterator( emplace_at( head(), std::forward(args)... )); } -# endif /// Find the key \p val /** \anchor cds_nonintrusive_MichaelList_nogc_find_val @@ -395,12 +369,12 @@ namespace cds { namespace container { //@cond node_type * insert_node_at( head_type& refHead, node_type * pNode ) { - assert( pNode != null_ptr() ); + assert( pNode != nullptr ); scoped_node_ptr p(pNode); if ( base_class::insert_at( refHead, *pNode )) return p.release(); - return null_ptr(); + return nullptr; } template @@ -413,29 +387,21 @@ namespace cds { namespace container { std::pair< node_type *, bool > ensure_at( head_type& refHead, const Q& val ) { scoped_node_ptr pNode( alloc_node( val )); - node_type * pItemFound = null_ptr(); + 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 != null_ptr() ); + assert( pItemFound != nullptr ); if ( ret.first && ret.second ) pNode.release(); return std::make_pair( pItemFound, ret.second ); } -# ifdef CDS_EMPLACE_SUPPORT template node_type * emplace_at( head_type& refHead, Args&&... args ) { return insert_node_at( refHead, alloc_node( std::forward(args)...)); } -# endif template node_type * find_at( head_type& refHead, Q const& key, Compare cmp )