forked from boostorg/container
Implemented SCARY iterators for all containers
[SVN r85308]
This commit is contained in:
1 parent
d91dc0059b
commit
3d249fa728
14 files changed
+559
-792
No files matched your search
@@ -24,6 +24,7 @@
|
||||
#include <boost/move/detail/move_helpers.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/iterators.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
@@ -69,8 +70,16 @@ struct slist_node
|
||||
slist_node();
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef typename slist_hook<VoidPointer>::type hook_type;
|
||||
|
||||
T m_data;
|
||||
|
||||
T &get_data()
|
||||
{ return this->m_data; }
|
||||
|
||||
const T &get_data() const
|
||||
{ return this->m_data; }
|
||||
};
|
||||
|
||||
template<class Allocator>
|
||||
@@ -95,93 +104,6 @@ struct intrusive_slist_type
|
||||
typedef container_type type ;
|
||||
};
|
||||
|
||||
template<class T, class IIterator>
|
||||
class slist_const_iterator
|
||||
: public std::iterator< std::forward_iterator_tag, T
|
||||
, typename iiterator_types<T, IIterator>::difference_type
|
||||
, typename iiterator_types<T, IIterator>::const_pointer
|
||||
, typename iiterator_types<T, IIterator>::const_reference>
|
||||
{
|
||||
protected:
|
||||
|
||||
IIterator m_it;
|
||||
|
||||
public:
|
||||
typedef typename iiterator_types<T, IIterator>::const_pointer const_pointer;
|
||||
typedef typename iiterator_types<T, IIterator>::const_reference const_reference;
|
||||
|
||||
//Constructors
|
||||
slist_const_iterator()
|
||||
: m_it()
|
||||
{}
|
||||
|
||||
explicit slist_const_iterator(const IIterator &it)
|
||||
: m_it(it)
|
||||
{}
|
||||
|
||||
//Pointer like operators
|
||||
const_reference operator*() const
|
||||
{ return this->m_it->m_data; }
|
||||
|
||||
const_pointer operator->() const
|
||||
{ return ::boost::intrusive::pointer_traits<const_pointer>::pointer_to(this->m_it->m_data); }
|
||||
|
||||
//Increment / Decrement
|
||||
slist_const_iterator& operator++()
|
||||
{ ++this->m_it; return *this; }
|
||||
|
||||
slist_const_iterator operator++(int)
|
||||
{ IIterator tmp = this->m_it; ++*this; return slist_const_iterator(tmp); }
|
||||
|
||||
//Comparison operators
|
||||
friend bool operator== (const slist_const_iterator& l, const slist_const_iterator& r)
|
||||
{ return l.m_it == r.m_it; }
|
||||
|
||||
friend bool operator!= (const slist_const_iterator& l, const slist_const_iterator& r)
|
||||
{ return l.m_it != r.m_it; }
|
||||
|
||||
const IIterator &get() const
|
||||
{ return this->m_it; }
|
||||
};
|
||||
|
||||
template<class T, class IIterator>
|
||||
class slist_iterator
|
||||
: public slist_const_iterator<T, IIterator>
|
||||
{
|
||||
private:
|
||||
typedef slist_const_iterator<T, IIterator> const_iterator;
|
||||
|
||||
public:
|
||||
typedef typename iiterator_types<T, IIterator>::pointer pointer;
|
||||
typedef typename iiterator_types<T, IIterator>::reference reference;
|
||||
|
||||
//Constructors
|
||||
slist_iterator()
|
||||
: const_iterator()
|
||||
{}
|
||||
|
||||
explicit slist_iterator(const IIterator &it)
|
||||
: const_iterator(it)
|
||||
{}
|
||||
|
||||
//Pointer like operators
|
||||
reference operator*() const
|
||||
{ return this->m_it->m_data; }
|
||||
|
||||
pointer operator->() const
|
||||
{ return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->m_it->m_data); }
|
||||
|
||||
//Increment / Decrement
|
||||
slist_iterator& operator++()
|
||||
{ ++this->m_it; return *this; }
|
||||
|
||||
slist_iterator operator++(int)
|
||||
{ IIterator tmp = this->m_it; ++*this; return slist_iterator(tmp); }
|
||||
|
||||
const IIterator &get() const
|
||||
{ return this->m_it; }
|
||||
};
|
||||
|
||||
} //namespace container_detail {
|
||||
|
||||
/// @endcond
|
||||
@@ -271,8 +193,8 @@ class slist
|
||||
};
|
||||
|
||||
BOOST_COPYABLE_AND_MOVABLE(slist)
|
||||
typedef container_detail::slist_iterator<T, typename Icont::iterator> iterator_impl;
|
||||
typedef container_detail::slist_const_iterator<T, typename Icont::iterator>const_iterator_impl;
|
||||
typedef container_detail::iterator<typename Icont::iterator, false> iterator_impl;
|
||||
typedef container_detail::iterator<typename Icont::iterator, true > const_iterator_impl;
|
||||
/// @endcond
|
||||
|
||||
public:
|
||||
@@ -451,7 +373,6 @@ class slist
|
||||
}
|
||||
//If unequal allocators, then do a one by one move
|
||||
else{
|
||||
typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
|
||||
this->assign( boost::make_move_iterator(x.begin())
|
||||
, boost::make_move_iterator(x.end()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user