inconsistent behaviour of const_iterator and const_reverse_iterator

Discussion in 'C++' started by Serengeti, Nov 20, 2005.

  1. Serengeti

    Serengeti Guest

    hello,
    I've had some hard time trying to understand why does this code
    compile:
    http://cpp.sourceforge.net/?show=10151 (*)
    while this doesn't:
    http://cpp.sourceforge.net/?show=10150 (**)

    Any insights would be greatly appreciated.
    tia,
    Slawek


    (*)
    #include <vector>
    using std::vector;

    int main()
    {
    vector<double> vect;
    for(vector<double>::const_iterator v = vect.begin(); v !=
    vect.end(); v++);
    }

    (**)
    #include <vector>
    using std::vector;

    int main()
    {
    vector<double> vect;
    for(vector<double>::const_reverse_iterator v = vect.rbegin(); v !=
    vect.rend(); v++);
    }
     
    Serengeti, Nov 20, 2005
    #1
    1. Advertising

  2. Serengeti wrote:
    > hello,
    > I've had some hard time trying to understand why does this code
    > compile:
    > http://cpp.sourceforge.net/?show=10151 (*)
    > while this doesn't:
    > http://cpp.sourceforge.net/?show=10150 (**)
    >
    > Any insights would be greatly appreciated.
    > tia,
    > Slawek
    >
    >
    > (*)
    > #include <vector>
    > using std::vector;
    >
    > int main()
    > {
    > vector<double> vect;
    > for(vector<double>::const_iterator v = vect.begin(); v !=
    > vect.end(); v++);
    > }
    >
    > (**)
    > #include <vector>
    > using std::vector;
    >
    > int main()
    > {
    > vector<double> vect;
    > for(vector<double>::const_reverse_iterator v = vect.rbegin(); v !=
    > vect.rend(); v++);
    > }


    This is a defect:
    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#280


    Jonathan
     
    Jonathan Mcdougall, Nov 20, 2005
    #2
    1. Advertising

  3. Serengeti

    Serengeti Guest

    Thanks.

    Slawek
     
    Serengeti, Nov 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Razvan

    Inconsistent behaviour

    Razvan, Oct 3, 2004, in forum: Java
    Replies:
    19
    Views:
    555
    Carl Howells
    Oct 11, 2004
  2. Spoon
    Replies:
    1
    Views:
    522
    Ivan Vecerina
    Mar 23, 2007
  3. Jess
    Replies:
    20
    Views:
    729
    James Kanze
    Jun 21, 2007
  4. , India
    Replies:
    2
    Views:
    1,668
    Kai-Uwe Bux
    Oct 4, 2007
  5. , India
    Replies:
    1
    Views:
    450
    James Kanze
    Aug 16, 2009
Loading...

Share This Page