This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

std::vector<T>::const_reverse_iterator


I just started using gcc-3.0 and found that the
code that follows will not compile:

#include <iostream>
#include <string>
#include <vector>

int main()
{
        std::vector<std::string> v;
        v.push_back("aaa");
        v.push_back("bbb");
        v.push_back("ccc");
        std::vector<std::string>::const_reverse_iterator iter;

        for (iter = v.rbegin(); iter != v.rend(); ++iter)
                std::cout << *iter << std::endl;
}


I get the following errors:

g++     foobar.cc   -o foobar
foobar.cc: In function `int main()':
foobar.cc:13: no match for
`std::reverse_iterator<std::__normal_iterator<const
   std::string*, std::vector<std::string, std::allocator<std::string> >
> >& !=
   std::reverse_iterator<std::__normal_iterator<std::string*,
   std::vector<std::string, std::allocator<std::string> > > >' operator
make: *** [foobar] Error 1

This problem does not occur when I change the const_reverse_iterator to
const_iterator and remove the leading 'r' from begin and end. I think
the
example with the reverse iterator should work. Am I wrong?

Dean Hoover


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