Re: no match for complain

From: SaltPeter (SaltPeter_at_Jupiter.sys)
Date: 06/29/04

Date: Tue, 29 Jun 2004 03:19:35 -0400

"Edo" <> wrote in message
> Hello
> what is the problem. I declared every thing "I think" right, why it is
> complaining
> Untitled1.cpp:16: no match for `std::_List_iterator<double, double&,
> double*>& < std::_List_iterator<double, double&, double*>' operator

Its not complaining, its telling you that no operator > is defined for an
iterator. And thats a good thing once you start to understand iterators,
including reverse iterators. Iterators are not meant to be compared with
each other.

Why aren't you reading up on how to initialize and step through a sequence
of iterators? The same goes for the universal push and pop STL container
member functions? Since these are common in that most containers (with the
appropriate exceptions) rely on a consistent function naming convention.


std::vector<int> vn;

std::deque<int> dn;

std::list<int> ln;

and the same can be said for their iterators (albeit there are various types
of iterators).

> thanks
> #include <iostream>
> using std::cout;
> using std::endl;
> #include <list>
> using std::list;
> int main()
> {
> list<double>::iterator it;
> list<double> lst;
> *it = 34;

Why are you using an undefined iterator?

Declare the empty list, "push_back()" onto it, then set the iterator to a
given end. Then iterate through the sequence in std::list container. Its
exactly the same procedure for a vector, list, queue, etc...

If you want to provide an index number during output, then code one in.


#include <iostream>
#include <list>

int main()
    std::list<double> dlist;
    std::list<double>::iterator iter;


    int index = 1;
    for (iter = dlist.begin(); iter != dlist.end(); ++iter)
        std::cout << index++ << '\t' << *iter << std::endl;

    return 0;

Relevant Pages

  • Re: Under what circumstances can the STL move a vector?
    ... > vector in the first element on the heap is moved, thus invalidating ... Each container has well defined semantics on how and when iterators ... and references into the container become invalidated. ...
  • Re: Interface of the set classes
    ... > container usually depend on the data set. ... > templates, iterators, probably tags, and on. ... Python has iterators, and doesn't need templates, since signature based ... The equivalent of "specializing a template" ...
  • Re: Reinventing the iterator
    ... this environmental benefit from iterators. ... the container once from beginning to end. ... iterator-based algorithms are good for any ... (defmethod find (item (container array)) ...
  • Re: Seed7 Release 2007-05-07
    ... You do not need iterators ... I am sure it is possible to declare ... Iterators in Seed7. ... I meant different container types. ...
  • Re: iterator invalidation trouble
    ... > You say the user shouldn't know if the container has changed, ... I only want to store non zero elements. ... I considered not deleting *_it_ immediately, ... simpler solution than registering iterators with their container? ...