static CDS_CONSTEXPR bool const c_bSort = base_class::c_bSort; ///< List type: ordered (\p true) or unordered (\p false)
+ //@cond
+ // Rebind traits (split-list support)
+ template <typename... Options>
+ struct rebind_traits {
+ typedef LazyList<
+ gc
+ , value_type
+ , typename cds::opt::make_options< traits, Options...>::type
+ > type;
+ };
+
+ // Stat selector
+ template <typename Stat>
+ using select_stat_wrapper = typename base_class::template select_stat_wrapper< Stat >;
+ //@endcond
+
protected:
//@cond
typedef typename base_class::value_type node_type;
typedef typename base_class::key_comparator intrusive_key_comparator;
typedef typename base_class::node_type head_type;
- //@endcond
-
- protected:
- //@cond
- static value_type& node_to_value( node_type& n )
- {
- return n.m_Value;
- }
-
- static node_type * alloc_node()
- {
- return cxx_allocator().New();
- }
-
- static node_type * alloc_node( value_type const& v )
- {
- return cxx_allocator().New( v );
- }
-
- template <typename... Args>
- static node_type * alloc_node( Args&&... args )
- {
- return cxx_allocator().MoveNew( std::forward<Args>(args)... );
- }
-
- static void free_node( node_type * pNode )
- {
- cxx_allocator().Delete( pNode );
- }
struct node_disposer {
void operator()( node_type * pNode )
}
};
typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr;
-
- head_type& head()
- {
- return base_class::m_Head;
- }
-
- head_type const& head() const
- {
- return base_class::m_Head;
- }
-
- head_type& tail()
- {
- return base_class::m_Tail;
- }
-
- head_type const& tail() const
- {
- return base_class::m_Tail;
- }
//@endcond
protected:
}
//@}
- protected:
- //@cond
- iterator node_to_iterator( node_type * pNode )
- {
- if ( pNode )
- return iterator( *pNode );
- return end();
- }
- //@endcond
-
public:
/// Default constructor
LazyList()
Return an iterator pointing to inserted item if success \ref end() otherwise
*/
template <typename Q>
- iterator insert( Q const& val )
+ iterator insert( Q&& val )
{
- return node_to_iterator( insert_at( head(), val ) );
+ return node_to_iterator( insert_at( head(), std::forward<Q>( val )) );
}
/// Inserts data of type \p value_type created from \p args
/// Updates the item
/**
If \p key is not in the list and \p bAllowInsert is \p true,
-
the function inserts a new item.
Otherwise, the function returns an iterator pointing to the item found.
already is in the list.
*/
template <typename Q>
- std::pair<iterator, bool> update( Q const& val, bool bAllowInsert = true )
+ std::pair<iterator, bool> update( Q&& val, bool bAllowInsert = true )
{
- std::pair< node_type *, bool > ret = update_at( head(), val, bAllowInsert );
+ std::pair< node_type *, bool > ret = update_at( head(), std::forward<Q>( val ), bAllowInsert );
return std::make_pair( node_to_iterator( ret.first ), ret.second );
}
//@cond
protected:
//@cond
+ static value_type& node_to_value( node_type& n )
+ {
+ return n.m_Value;
+ }
+
+ static node_type * alloc_node()
+ {
+ return cxx_allocator().New();
+ }
+
+ static node_type * alloc_node( value_type const& v )
+ {
+ return cxx_allocator().New( v );
+ }
+
+ template <typename... Args>
+ static node_type * alloc_node( Args&&... args )
+ {
+ return cxx_allocator().MoveNew( std::forward<Args>( args )... );
+ }
+
+ static void free_node( node_type * pNode )
+ {
+ cxx_allocator().Delete( pNode );
+ }
+
+ head_type& head()
+ {
+ return base_class::m_Head;
+ }
+
+ head_type const& head() const
+ {
+ return base_class::m_Head;
+ }
+
+ head_type& tail()
+ {
+ return base_class::m_Tail;
+ }
+
+ head_type const& tail() const
+ {
+ return base_class::m_Tail;
+ }
+
+ iterator node_to_iterator( node_type * pNode )
+ {
+ if ( pNode )
+ return iterator( *pNode );
+ return end();
+ }
+
iterator insert_node( node_type * pNode )
{
return node_to_iterator( insert_node_at( head(), pNode ));
}
template <typename Q>
- node_type * insert_at( head_type& refHead, Q const& val )
+ node_type * insert_at( head_type& refHead, Q&& val )
{
- return insert_node_at( refHead, alloc_node( val ));
+ return insert_node_at( refHead, alloc_node( std::forward<Q>( val )));
}
template <typename... Args>
}
template <typename Q>
- std::pair< node_type *, bool > update_at( head_type& refHead, Q const& val, bool bAllowInsert )
+ std::pair< node_type *, bool > update_at( head_type& refHead, Q&& val, bool bAllowInsert )
{
- scoped_node_ptr pNode( alloc_node( val ));
+ scoped_node_ptr pNode( alloc_node( std::forward<Q>( val )));
node_type * pItemFound = nullptr;
std::pair<bool, bool> ret = base_class::update_at( &refHead, *pNode,
- [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; },
+ [&pItemFound](bool, node_type& item, node_type&) { pItemFound = &item; },
bAllowInsert );
if ( ret.second )