This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/52433] [C++11] debug mode iterators need to move


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]