push-back

crash on vector::push_back

I have a vector that contains POSITIONs. When I try to push_back or clear, the program crashes. The callstack shows _invalid_parameter_noinfo in one of the frames. I googled and found a solution(defining _HAS_ITERA.... and _SECURE_SCL to 0) , but was not effective. I'm using VS2008 with MFC feature pack installed on vista. Please help. ...

manipulation of Vectors created with new

Can anyone help with this... vector<unsigned int> *vVec = new vector<unsigned int>; vVec .reserve(frankReservedSpace); start = std::clock(); for(int f=0; f<sizeOfvec; f++) { //Populate the newly created vector on the heap vVec .push_back(pArray[f]); } I'm getting: error C2228: left...

linker problem a list of const reference::push_back in boost::lambda::if_then

Hi experts, The following codes compiled and linked fine with g++-4.0 on a Mac OSX for_each(As.begin(), As.end(), boost::lambda::if_then( boost::lambda::bind(&A::get_string, boost::lambda::_1)==" CA ", boost::lambda::bind(&std::list<A>::push_back, &As_copy, boost::lambda::_1) ) ); But when I try to populate a conta...

Causing push_back in vector<int> to segmentaion fault on what seems to be simple operation

I'm working on a program for Project Euler to add all the digits of 2^1000. So far I've been able to track the program segmentation faults when it reaches around 5 digits and tries to push a one onto the vector at line 61 in the function carry(). #include <iostream> #include <vector> #include <string> using namespace std; class MegaN...

C++ vector push_back() overwrites on another vector of the same type?

I defined a class named nth_best_parse this way: class nth_best_parse { public: int traversal; int nth_best_active; int nth_best_passive; double viterbi_prob; nth_best_parse(); nth_best_parse(int t, int nbl, int nbr, double v) {traversal = t; nth_best_active = nbl; nth_best_passive ...

push_back() and push_front() in Java

Is there any collection class in java, that implements push_back() and push_front() methods? ...

[C++] Vector (push_back); g++ -O2; Segmentation fault

I'm having problem with vector, (in the usage of push_back) but it only appears when using additional g++ flag -O2 (I need it). #include <cstdio> #include <vector> typedef std::vector<int> node; typedef std::vector<node> graph; int main() { int n, k, a, b, sum; bool c; graph g(n, node()); c = scanf("%i%i", &n, &k); ...

pushing back an boost::ptr_vector<...>::iterator in another boost::ptr_vector?

Hi all, I have the following code (just typed it in here, might have typos or stuff): typedef boost::ptr_vector<SomeClass> tvec; tvec v; // ... fill v ... tvec vsnap; for(tvec::iterator it = v.begin(); it != v.end(); ++it) { if((*v).anyCondition) vsnap.push_back( it ); // (*it) or &(*it) doesn't work } My problem is now ...

Vector does reallocation on every push_back

IDE - Visual Studio 2008, Visual C++ I have a custom class Class1 with a copy constructor to it. I also have a vector Data is inserted using the following code Class1* objClass1; vector<Class1> vClass1; for(int i=0;i<1000;i++) { objClass1 = new Class1(); vClass1.push_back(*objClass1); delete objClass1; } Now...

push_back private vectors with 2 methods, one isn't working

I have a class with a private vector of doubles. To access or modify these values, at first I used methods such as void classA::pushVector(double i) { this->vector.push_back(i); } double classA::getVector(int i) { return vector[i]; } This worked for a while until I found I would have to overload a lot of operators for what I needed, s...

Vector push_back Access Violation

This is probably a silly error, but it's driving me nuts trying to fix it. I have a struct: struct MarkerData { int pattId; unsigned short boneId; Ogre::Matrix4 transToBone; Ogre::Vector3 translation; Ogre::Quaternion orientation; MarkerData(int p_id, unsigned short b_id, Ogre::Matrix4 trans) { pattId = p_id; boneId = b_i...