stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject 23.deque.special
Date Fri, 06 Jul 2007 17:01:29 GMT

  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 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