21 namespace cxx {
namespace Bits {
23 template<
typename T >
24 class List_iterator_end_ptr
27 template<
typename U >
friend class Basic_list;
31 template<
typename T >
32 void *List_iterator_end_ptr<T>::_end;
34 template<
typename VALUE_T,
typename TYPE >
35 struct Basic_list_policy
37 typedef VALUE_T *Value_type;
38 typedef VALUE_T
const *Const_value_type;
40 typedef TYPE *Const_type;
41 typedef TYPE *Head_type;
42 typedef TYPE Item_type;
44 static Type next(Type c) {
return static_cast<Type
>(&(*c)->_n); }
45 static Const_type next(Const_type c) {
return static_cast<Const_type
>(c->_n); }
49 template<
typename POLICY >
57 typedef typename POLICY::Value_type Value_type;
58 typedef typename POLICY::Const_value_type Const_value_type;
63 typedef typename POLICY::Type Internal_type;
66 typedef typename POLICY::Value_type value_type;
67 typedef typename POLICY::Value_type Value_type;
69 Value_type operator * ()
const {
return static_cast<Value_type
>(*_c); }
70 Value_type operator -> ()
const {
return static_cast<Value_type
>(*_c); }
71 Iterator operator ++ () { _c = POLICY::next(_c);
return *
this; }
73 bool operator == (Iterator
const &o)
const {
return *_c == *o._c; }
74 bool operator != (Iterator
const &o)
const {
return !operator == (o); }
76 Iterator() : _c(__end()) {}
80 static Internal_type __end()
82 union X { Internal_type l;
void **v; } z;
83 z.v = &Bits::List_iterator_end_ptr<void>::_end;
87 explicit Iterator(Internal_type i) : _c(i) {}
95 typedef typename POLICY::Const_type Internal_type;
98 typedef typename POLICY::Value_type value_type;
99 typedef typename POLICY::Value_type Value_type;
101 Value_type operator * ()
const {
return static_cast<Value_type
>(_c); }
102 Value_type operator -> ()
const {
return static_cast<Value_type
>(_c); }
103 Const_iterator operator ++ () { _c = POLICY::next(_c);
return *
this; }
105 friend bool operator == (Const_iterator
const &lhs, Const_iterator
const &rhs)
106 {
return lhs._c == rhs._c; }
107 friend bool operator != (Const_iterator
const &lhs, Const_iterator
const &rhs)
108 {
return lhs._c != rhs._c; }
110 Const_iterator() : _c(0) {}
111 Const_iterator(Iterator
const &o) : _c(*o) {}
116 explicit Const_iterator(Internal_type i) : _c(i) {}
128 Value_type
front()
const {
return static_cast<Value_type
>(_f); }
138 Iterator
begin() {
return Iterator(&_f); }
140 Const_iterator
begin()
const {
return Const_iterator(_f); }
148 static Const_iterator
iter(Const_value_type c) {
return Const_iterator(c); }
150 Const_iterator
end()
const {
return Const_iterator(
nullptr); }
152 Iterator
end() {
return Iterator(); }
155 static typename POLICY::Type __get_internal(Iterator
const &i) {
return i._c; }
156 static Iterator __iter(
typename POLICY::Type c) {
return Iterator(c); }
159 typename POLICY::Head_type
_f;
Const_iterator begin() const
Return a const iterator to the beginning of the list.
Internal: Common functions for all head-based list implementations.
Value_type front() const
Return the first element in the list.
void clear()
Remove all elements from the list.
Iterator end()
Return an iterator to the end of the list.
static Const_iterator iter(Const_value_type c)
Return a const iterator that begins at the given element.
POLICY::Head_type _f
Pointer to front of the list.
Const_iterator end() const
Return a const iterator to the end of the list.
Iterator begin()
Return an iterator to the beginning of the list.
bool empty() const
Check if the list is empty.