Avoid copying a singular iterator.
Found a better way to avoid copying singular iterators. Gabba, tschmitz please review the code and if it's correct it should be save to revert 2011-10-23T17:48:59Z!koraq@xs4all.nl.
This commit is contained in:
parent
c1c40064eb
commit
b9da475424
2 changed files with 14 additions and 0 deletions
|
@ -86,6 +86,7 @@ Version 1.9.9+svn:
|
|||
* Fix gold carryover if loading a save created in linger mode (bug #16111)
|
||||
* Fixed: Compilation with boost 1.47 (bug #18399's patch).
|
||||
* Fixed: Compilation with the clang 2.9 compiler (bug #18399's patch).
|
||||
* Fixed: Avoid copying of singular iterators in the whiteboard code.
|
||||
|
||||
Version 1.9.9:
|
||||
* AI:
|
||||
|
|
|
@ -309,6 +309,19 @@ public:
|
|||
, contents_(that.base().contents_)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* If the contents_ is NULL the iterator is singular. Copying singular
|
||||
* iterators is UB, so avoid it.
|
||||
*/
|
||||
iterator(const iterator& that)
|
||||
: base_(that.contents_ ? that.base_ : base_t())
|
||||
, turn_num_(that.contents_ ? that.turn_num_ : 0)
|
||||
, contents_(that.contents_)
|
||||
{
|
||||
}
|
||||
|
||||
action_ptr& operator*() const {return *base_;}
|
||||
action_ptr* operator->() const {return base_.operator->();}
|
||||
this_t& operator++()
|
||||
|
|
Loading…
Add table
Reference in a new issue