incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject RE: 23.deque.special
Date Mon, 09 Jul 2007 19:26:01 GMT
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Monday, July 09, 2007 10:05 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: 23.deque.special
> 
> >   But in current implementation iterator not invalidated. Yes, it's 
> > mebmers has changed, but it's still valid "end iterator".
> 
> But it doesn't point to the right container. Unless I'm still 
> missing something this needs to pass:

  No. It point to the right container.

  std::deque<int> x, y;

  x._C_end._C_node always == &x._C_end._C_cur for empty container x

  This condition is required by current design (include/deque, line 663)

    void _C_init () {
        // clear both `beg.cur' and `end.cur' and set both `beg.node'
        // and `end.node' to point to `end.cur' (instead of 0) to avoid
        // having to check before dereferencing the pointers
        _C_beg       =
        _C_end       = _C_deque_iter (pointer (), &_C_end._C_cur);
        _C_nodes     = _C_node_pointer ();
        _C_node_size = 0;
    }

  After x.swap (y) operation x._C_end._C_node still should point to
&x._C_end._C_cur,
but not to &y._C_end._C_cur to be a valid "end iterator" of the
container x.

> >   If we decide to set deque<>._C_end._C_node = 0 for end 
> iterator of 
> > empty deque It would be a big change (we should change the 
> all places 
> > where _C_end._C_node member dereferenced).
> 
> Couldn't we just repoint _C_end._C_node in swap()?

http://svn.apache.org/viewvc?view=rev&revision=507940

  Here I repoint _C_end._C_node to the value required by current design
after binary _STD::swap (_C_end, __rhs._C_end);

Farid.

Mime
View raw message