Dereferemce operators in both iterators are now const; this fixes iterator compatibility with parts of Boost Iterator (i.e. filter_iterator). It is now possible to damage the state of const_iterator by directly mutating internal handle - working around that introduces additional performance penalties and is generally extremely unlikely to be useful - constant iterator objects are rarely used.

git-svn-id: http://pugixml.googlecode.com/svn/trunk@858 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine@gmail.com 2012-03-14 05:34:00 +00:00
parent 23f891a92b
commit e4ae729370
2 changed files with 10 additions and 10 deletions

View File

@ -4652,13 +4652,13 @@ namespace pugi
return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root;
} }
PUGI__FN xml_node& xml_node_iterator::operator*() PUGI__FN xml_node& xml_node_iterator::operator*() const
{ {
assert(_wrap._root); assert(_wrap._root);
return _wrap; return _wrap;
} }
PUGI__FN xml_node* xml_node_iterator::operator->() PUGI__FN xml_node* xml_node_iterator::operator->() const
{ {
assert(_wrap._root); assert(_wrap._root);
return &_wrap; return &_wrap;
@ -4713,13 +4713,13 @@ namespace pugi
return _wrap._attr != rhs._wrap._attr || _parent._root != rhs._parent._root; return _wrap._attr != rhs._wrap._attr || _parent._root != rhs._parent._root;
} }
PUGI__FN xml_attribute& xml_attribute_iterator::operator*() PUGI__FN xml_attribute& xml_attribute_iterator::operator*() const
{ {
assert(_wrap._attr); assert(_wrap._attr);
return _wrap; return _wrap;
} }
PUGI__FN xml_attribute* xml_attribute_iterator::operator->() PUGI__FN xml_attribute* xml_attribute_iterator::operator->() const
{ {
assert(_wrap._attr); assert(_wrap._attr);
return &_wrap; return &_wrap;

View File

@ -597,7 +597,7 @@ namespace pugi
friend class xml_node; friend class xml_node;
private: private:
xml_node _wrap; mutable xml_node _wrap;
xml_node _parent; xml_node _parent;
xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent); xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent);
@ -623,8 +623,8 @@ namespace pugi
bool operator==(const xml_node_iterator& rhs) const; bool operator==(const xml_node_iterator& rhs) const;
bool operator!=(const xml_node_iterator& rhs) const; bool operator!=(const xml_node_iterator& rhs) const;
xml_node& operator*(); xml_node& operator*() const;
xml_node* operator->(); xml_node* operator->() const;
const xml_node_iterator& operator++(); const xml_node_iterator& operator++();
xml_node_iterator operator++(int); xml_node_iterator operator++(int);
@ -639,7 +639,7 @@ namespace pugi
friend class xml_node; friend class xml_node;
private: private:
xml_attribute _wrap; mutable xml_attribute _wrap;
xml_node _parent; xml_node _parent;
xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent); xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
@ -665,8 +665,8 @@ namespace pugi
bool operator==(const xml_attribute_iterator& rhs) const; bool operator==(const xml_attribute_iterator& rhs) const;
bool operator!=(const xml_attribute_iterator& rhs) const; bool operator!=(const xml_attribute_iterator& rhs) const;
xml_attribute& operator*(); xml_attribute& operator*() const;
xml_attribute* operator->(); xml_attribute* operator->() const;
const xml_attribute_iterator& operator++(); const xml_attribute_iterator& operator++();
xml_attribute_iterator operator++(int); xml_attribute_iterator operator++(int);