#ifndef __CDS_CONTAINER_MICHAEL_LIST_NOGC_H
#define __CDS_CONTAINER_MICHAEL_LIST_NOGC_H
-#include <cds/container/michael_list_base.h>
+#include <memory>
+#include <cds/container/details/michael_list_base.h>
#include <cds/intrusive/michael_list_nogc.h>
#include <cds/container/details/make_michael_list.h>
-#include <cds/details/std/memory.h>
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()
return cxx_allocator().New( v );
}
-# ifdef CDS_EMPLACE_SUPPORT
template <typename... Args>
static node_type * alloc_node( Args&&... args )
{
return cxx_allocator().MoveNew( std::forward<Args>(args)... );
}
-# endif
static void free_node( node_type * pNode )
{
value_ptr operator ->() const
{
typename iterator_base::value_ptr p = iterator_base::operator ->();
- return p ? &(p->m_Value) : reinterpret_cast<value_ptr>(NULL);
+ return p ? &(p->m_Value) : nullptr;
}
value_ref operator *() const
/// Returns an iterator that addresses the location succeeding the last element in a list
/**
Do not use the value returned by <tt>end</tt> function to access any item.
- Internally, <tt>end</tt> returning value equals to <tt>NULL</tt>.
+ Internally, <tt>end</tt> 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
return std::make_pair( node_to_iterator( ret.first ), ret.second );
}
-# ifdef CDS_EMPLACE_SUPPORT
/// Inserts data of type \ref value_type constructed with <tt>std::forward<Args>(args)...</tt>
/**
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 <typename... Args>
iterator emplace( Args&&... args )
{
return node_to_iterator( emplace_at( head(), std::forward<Args>(args)... ));
}
-# endif
/// Find the key \p val
/** \anchor cds_nonintrusive_MichaelList_nogc_find_val
scoped_node_ptr pNode( alloc_node( val ));
node_type * pItemFound = nullptr;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&) { pItemFound = &item; });
-# else
- ensure_functor func;
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, boost::ref(func) );
- pItemFound = func.m_pItemFound;
-# endif
assert( pItemFound != nullptr );
if ( ret.first && ret.second )
return std::make_pair( pItemFound, ret.second );
}
-# ifdef CDS_EMPLACE_SUPPORT
template <typename... Args>
node_type * emplace_at( head_type& refHead, Args&&... args )
{
return insert_node_at( refHead, alloc_node( std::forward<Args>(args)...));
}
-# endif
template <typename Q, typename Compare>
node_type * find_at( head_type& refHead, Q const& key, Compare cmp )