stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: 23.deque.special
Date Mon, 09 Jul 2007 04:39:53 GMT
Farid Zaripov wrote:
>   Below is a part of the 23.deque.special test. These rw_assert's
> fails because of deque::end() internal representation is dependent
> on object and cannot be swapped.

I'm not sure I understand. Swapping two deques is required not to
invalidate any iterators, isn't that right? Are you suggesting to
loosen the test so as not to exercise this requirement?

Martin

> 
>   I think that this part should be replaced to just checking
> deque.begin() == deque.end() after (and perhaps, before) the swap
> operation.
> 
> --------------
>     typedef std::deque<T, std::allocator<T> > MyDeque;
>     typedef typename MyDeque::iterator        Iterator;
> 
>     // create two empty deque objects
>     MyDeque empty [2];
> 
>     // save their begin and end iterators before calling swap
>     const Iterator before [2][2] = {
>         { empty [0].begin (), empty [0].end () },
>         { empty [1].begin (), empty [1].end () }
>     };
> 
>     // swap the two containers
>     empty [0].swap (empty [1]);
> 
>     // get the new begin and end iterators
>     const Iterator after [2][2] = {
>         { empty [0].begin (), empty [0].end () },
>         { empty [1].begin (), empty [1].end () }
>     };
> 
>     // verify that the iterators have not been invalidated
>     rw_assert (   before [0][0] == after [1][0] 
>                && before [1][0] == after [0][0], 0, __LINE__, 
>                "deque<%s>().begin() not swapped", tname);
>     
>     rw_assert (   before [0][1] == after [1][1] 
>                && before [1][1] == after [0][1], 0, __LINE__, 
>                "deque<%s>().end() not swapped", tname);
> --------------
> 
> Farid.
> 


Mime
View raw message