-2
我想對我的代碼發表意見。我需要一個隨機訪問迭代器來定製容器。 如果我讀的C++標準2011,特別是第24章,我明白了一個實現 可能是以下幾點:在C++ 2011中創建自定義隨機訪問迭代器
class my_iterator : public std::iterator<std::random_access_iterator_tag, my_element>
{
private:
my_container *_ref;
my_iterator_state state; // some useful state
public:
my_iterator();
my_iterator (const my_iterator &);
my_iterator (my_iterator &&);
~my_iterator();
my_iterator &operator = (const my_iterator &);
my_iterator &operator = (my_iterator &&);
reference operator *();
my_iterator &operator ++();
bool operator != (my_iterator);
value_type operator *();
pointer operator ->();
my_iterator &operator *();
void operator ++ (int);
value_type operator ++ (int);
const my_iterator &operator ++ (int);
reference operator ++ (int);
my_iterator &operator --();
const my_iterator operator -- (int);
reference operator -- (int);
my_iterator &operator += (difference_type);
my_iterator operator + (difference_type);
my_iterator operator - (difference_type);
reference operator [] (difference_type);
bool operator < (my_iterator);
bool operator > (my_iterator);
bool operator <= (my_iterator);
bool operator >= (my_iterator);
friend difference_type (my_iterator, my_iterator);
friend my_iterator operator + (difference_type, my_iterator);
friend void swap (iterator &, iterator &);
};
void swap (iterator &, iterator &);
difference_type (my_iterator, my_iterator);
my_iterator operator + (difference_type, my_iterator);
以上實施是正確的,功能齊全,?有太多成員?
呵呵,是的。請自己做一個服務並使用'boost :: iterator_facade'。 – 2013-05-10 14:31:16
歡迎來到Stack Overflow。請花時間閱讀 [faq]。你會得到一個[徽章](http://stackoverflow.com/badges)(c: – 2013-05-10 14:32:35
你可能會更好的問這個[codereview.se] – 2013-05-10 14:33:08