#include<bits/stdc++.h>
#include<bits/ptr_traits.h>
using namespace std;
int val;
struct my_iterator{
using element_type = int;
using value_type = int;
using reference = int&;
using pointer = int*;
using difference_type = ptrdiff_t;
using iterator_category = random_access_iterator_tag;
int pos;
my_iterator () = default;
my_iterator (int pos_ ) : pos(pos_){}
int& operator *(){
return val;
}
friend bool operator != (const my_iterator & a, const my_iterator& b){
return a.pos != b.pos;
}
void operator ++(){
++pos;
}
operator bool(){
return pos != 0;
}
};
template<typename T>
struct myallocator{
using value_type = T;
using pointer = my_iterator ;
myallocator(){}
template<typename U> myallocator(const myallocator<U>&&) {}
pointer reallocate(size_t count){
return my_iterator(0);
}
void deallocate(pointer p, size_t count){
;
}
};
int main(){
vector<int, myallocator<int> > v;
}
标签:不了,iterator,int,求助,pos,编译,operator,using,my
From: https://www.cnblogs.com/cdsidi/p/17099906.html