list容器
template <class T>
struct __list_node {
typedef void* void_pointer;
void_pointer prev;
void_pointer next;
T data;
};
template <class T,class Alloc = alloc>
class list {
protected:
typdef __list_node<T>list_node;
public:
typedef list_node* link_type;
typedef __list_iterator<T,T&,T*> iterator;
protected:
link_type node;
...
};
template<class T,class Ref, class Ptr>
struct __list_iterator {
typedef T value_type;
typedef Ptr pointer;
typedef Ref reference;
...
};
Iterator的++;
Iterator有对+操作符重载
Self operator++(int){ self tmp = *this; ++*this; retrun tmp;}; 如iterator++, 先记录原值,记录操作,返回原值
Self& operator++(){ node =(link_type)( (*node).next);, return *this;}: 如++iterator
Int i(6);
++++I; -> ++(++i);
I++++; -> i(++)++; //错误,不能加两次,所有一个返回的是Self operator++(int)
//
iterator == {一堆typedef + 操作符重载}
-
GNU2.9版本(size是4)
-
GNU 4.9(size是_List_node_base的大小8)
-