Why is joining two vectors simply not working?

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2012-10-23T22:58:00Z Indexed on 2012/10/23 23:00 UTC
Read the original article Hit count: 168

Filed under:
|
|

I have two vectors of MyObj structs. MyObj is defined as follows:

struct MyObj
{
   float x, y;
   unsigned int data[8];
   unsigned int tmp[1];

   MyObj(const MyObj &m) 
   {
      x = m.x; y = m.y; 
      tmp[0] = 0;
      for (int i = 0; i < 8; ++i)
      {
         data[i] = m.data[i];
      }
   }
};

I then have two vectors...

vector<MyObj> v1; 
vector<MyObj> v2;
// both get data eventually.

v1.insert(v1.end(), v2.begin(), v2.end());

v2 has 3535004 elements in my experiment. v1 is similarly sized. I've also tried building a new vector and just using .push_back to build it from both vectors.

Essentially, when I try to merge the two vectors I just get an error from visual studio saying "Debug error! R6010, abort() has been called". Very non-useful...

So my question is: what could be causing this error, and how can I solve it? Thank you

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-studio-2010