A sequence type defined as part of the Standard Template Library.

learn more… | top users | synonyms

-1
votes
4answers
30 views

Getting the size in bytes of a vector [duplicate]

Sorry for this maybe simple and stupid question but I couldn't find it anywhere. I just don't know how to get the size in bytes of a std::vector. std::vector<int>MyVector; /* This will ...
0
votes
3answers
219 views

std::map<int, int> vs. vector of vector

I need a container to store a value (int) according to two attributes, source (int) and destination (int) i.e. when a source sends something to a destination, I need to store it as an element in a ...
-2
votes
3answers
75 views

Can not insert own structure in standard vector but string can

I made simple structure: struct sToken { std::string token; unsigned int lineNb; }; I want to insert this structure in standard vector using push_back() method, but when I do this: ...
-6
votes
1answer
56 views

syntax for creating a vector in c++ [closed]

Can someone please elaborate on the meaning of the following line of code in C++? std::vector<Bone<float> *> bones; I think it is creating a vector called bones, which is comprised of ...
0
votes
1answer
50 views

How to get a pointer to last inserted element of a std::vector?

I came up with the following snipped but it looks quite hacky. vector<int> collection; collection.push_back(42); int *pointer = &(*(collection.end()--)); Is there an easy way to get a ...
0
votes
2answers
33 views

C++ How to iterate over a vector defined as a super class, but call sub class methods?

I have a Java background and I am trying to understand polymorphism in C++. Specifically, how to iterate over a series of subclasses in a std vector defined by their super class, in order to call a ...
3
votes
1answer
107 views

BadPtr with vector<std::string> iterator in template function

I have a function that parses a .csv file and tokenizes each line using a "," as the delimiter. I tokenize it into a vector. I then iterate over that vector and convert each string to a number using a ...
1
vote
1answer
55 views

C++: Can I use a vector with placement new?

I'm working on a bit of a thought experiment here -- I'm trying to actually make my life easier here. I'm working with a data structure that, among other things, contains a couple of arrays of ...
0
votes
1answer
51 views

std::remove_if/find_if: Double free or corruption

I have the following std::map defined: //The map holding the list of registered services per partition key. std::map<SRServicePartitionKey, std::vector<EndPointAddr*>* > mServiceMap; ...
0
votes
2answers
65 views

STL Vector Swap Structure (C++)

What is the difference between someVector.clear(); std::vector<int> ().swap(someVector); and someVector.clear(); std::vector<int> (someVector).swap(someVector); Or do they accomplish ...
8
votes
4answers
375 views

a small issue with std::vector and changing the collection while looping through it

This loop changes the iterators while running: std::vector<int> c; c.push_back(1); c.push_back(2); std::vector<int>::iterator iter = c.begin(); std::vector<int>::iterator ...
2
votes
0answers
72 views

Remove elements (and change size) of std::vector without affecting allocated memory

I'm using code such as the following: const int MY_SIZE = 100000; std::vector<double> v; v.reserve(MY_SIZE); // add no more than MY_SIZE elements to the vector f(v); v.clear(); // again, ...
1
vote
2answers
86 views

Strange behavior when including <vector>

I see some very strange behavior when I include the standard vector library. Can anyone tell me what is causing these failures? Whose toes am I stepping on and is there a general case of this bug that ...
2
votes
5answers
83 views

std::remove_if: Removing all occurences of a pointer from std::vector

I have an std::vector instance as defined in the following line: std::vector< std::pair<EndPointAddr*, EndPointAddr*>* > mServiceSubscriptionsList; The first item in the underlying ...
1
vote
4answers
35 views

std::vector pushback throws EXC_BAD_ACCESS when used inside a C++ static method

I have a class Foo with a static factory method - Foo::createOne - that creates an instance and puts some data into a private member variable of type std:vector. When I call Foo::createOne, my ...

1 2 3 4 5 34
15 30 50 per page