   Weird problem with std copy
  Hi,This code crashes on the third line. And I cannot figure out what I am doing wrong.std::vector<float> abc,def;abc.push_back(3);std::copy(abc.begin(), abc.end(), def.end()); //debug assert error hereAny clues?Thanks.   
  Copy assumes that the destination is a valid range, the same size as the input.You could use std::back_inserter:#include <vector>#include <iterator>#include <iostream>#include <algorithm>int main(){    std::vector<float> abc, def;    abc.push_back(3);    std::copy(abc.begin(), abc.end(), std::back_inserter(def));    std::copy(def.begin(), def.end(), std::ostream_iterator<float>(std::cout,"\n"));}Or you could use resize() on def so that it has at least as many elements as abc.   ;  You can't use std::copy to copy directly to an empty vector. Since it doesn't contain any elements when std::copy tries to write to those non-existing elements bad things happen. In your case you might want to use def.assign(abc.begin(), abc.end()) or use std::back_inserter() for the destination for std::copy(). I recommend the former.   ;  Oh I see, I thought I'd used it similarly to my problem code before. I should've of checked the docs first :)Thanks guys.