This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/52433] [C++11] debug mode iterators need to move
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 29 Feb 2012 14:33:02 +0000
- Subject: [Bug libstdc++/52433] [C++11] debug mode iterators need to move
- Auto-submitted: auto-generated
- References: <bug-52433-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52433
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot |redi at gcc dot gnu.org
|gnu.org |
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-29 14:33:02 UTC ---
(In reply to comment #0)
>
> + /// @post @p __x is singular and unattached
> + _Safe_iterator(_Safe_iterator&& __x)
> + {
> + // _GLIBCXX_RESOLVE_LIB_DEFECTS
> + // DR 408. Is vector<reverse_iterator<char*> > forbidden?
> + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
> + || __x._M_current == _Iterator(),
> + _M_message(__msg_init_copy_singular)
> + ._M_iterator(*this, "this")
> + ._M_iterator(__x, "other"));
> + swap(*this, __x);
Doh, that will recursively call the move constructor.
We could do:
/// @post @p __x is singular and unattached
_Safe_iterator(_Safe_iterator&& __x)
{
*this = __x;
_Safe_iterator __singular;
__x = __singular;
}
but it would be more efficient to implement a swap() member and use that for
both move construction and move-assignment