Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

Expression: vector iterators incompatible

This topic is 1157 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;
    
    m_clouds.push_back(c);

...

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] )
        {
            m_clouds.erase(c);
        }
        else
            c++;
    }

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.

 

Shogun.

 

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!