Incorrect iterator type

I've got the following code:

typedef msec_t uint32_t;
std::list<std::pair<msec_t, SomeClass*>> timeouts;
std::list<std::pair<msec_t, SomeClass*>>::iterator itr = timeouts.begin();

CLion is claiming itr as type _Class_iterator<msec_t>, rather than the appropriate templated pair. As a result, any time I assign the iterator to something from the list, it reports as an error.

2 comments
Comment actions Permalink

Hi Patrick.

Your code does not produce errors for me (assuming that typedef is meant to be the other way around).

#include <list>

class SomeClass{
};

typedef uint32_t msec_t;
std::list<std::pair<msec_t, SomeClass*>> timeouts;
std::list<std::pair<msec_t, SomeClass*>>::iterator itr = timeouts.begin();

If not, please provide a compilable snippet for us to reproduce.

 

0
Comment actions Permalink

Ah. You got me on the typedef, certainly.

And when I wrote a similar piece of code myself, it indeed doesn't produce any error.

Yet, through various restarts and rewriting the lines in question in the project that I couldn't share as is, the error is reported.

Is there anything else I can do to help in debugging?

0

Please sign in to leave a comment.