Advertisement Jump to content
Sign in to follow this  

Expression: vector iterators incompatible

This topic is 1246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

No idea what's causing this.   I've searched google, and found absolutely no solutions as my problem was unique to every google result I came across.

/* Cloud structure */
struct cloud_t
    struct vec2_t<float>    pos;
    float                   vel;


/* Add a cloud to the list */
    struct cloud_t c;
    c.pos.v[0] = -160.0f;
    c.pos.v[1] = (float) m_rng.random( int( bounds.v[1] - 120 ) );
    c.vel = (float) m_rng.random(5)+1;


std::vector<cloud_t>::iterator c = m_clouds.begin();
    while( c != m_clouds.end() )
        c->pos.v[0] += c->vel * m_speed_factor * m_delta_speed;
        if( c->pos.v[0] >= bounds.v[0] )

How could this NOT work?  It works just fine on XCode, but in Visual Studio, it gives me a runtime error (see title) in debug mode.  It doesn't show up in Release builds, but I'm not stupid enough to ignore it.  Any ideas?  Thanks.




EDIT: Nevermind.  I didn't realize I forgot to do this:


c = m_clouds.erase(c);

Edited by blueshogun96

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!