I have a Foo object, and a std::list holding instances of it. My problem is that when I add a new instance to the list, it first calls the ctor but then also the dtor. And then the dtor on another instance (according to the this pointer).
A single instance is added to the list but since its dtor (along with its parents) is called, the o...
I have an class and I would like to use the standard library list to store a list of them. I essentially want to push_front() the list. So my code is like this:
#include <list>
/* ... lots of stuff ...*/
complexNode myObject();
std::list<complexNode> complexList();
myList.push_front(myObject);
But the compiler throws this error:
e...
How do people normally manage copying a list of large objects around?
Here's my situation:
Currently I have this:
typedef std::vector<float> Image;
and I'm storing it in a
std::list<Image> lst;
The Image.size() is quite large (each is ~3-5 MB).
I'm passing (copying) the list around.
Is it a correct understanding on my part that...
I'm working on a very basic game and I have a std::list collection of objects that pertain to my game. I declared it as:
std::list<Target> targets;
When I iterate over it, using
for (std::list<Target>::iterator iter = targets.begin(); iter != targets.end(); iter++) {
Target t = *iter;
t.move();
}
My objects are...
I have some C code, where in there are two linked lists(say A and B) and A is inserted at a particular position into B and A still has elements.
How do I simulate the same behavior effectively using the C++ STL? If I try splice, it makes the second one empty.
Thanks,
Gokul.
...
I have a client server application with multi-threading. The server side is failing with a std::list getting corrupted resulting in a SEGV. I suspect that there is some kind of cross thread timing issue going on where the two threads are updating the std::list at the same time and causing it to be corrupted.
Please suggest free tools ...
I have a class that contains, among other things, an std::list. I want to expose this list but only in such a way that the structure and the data it contains are read only, but still can be used with iterators.
The way I've got it 'working' atm is to return a copy of the list. This leave my class 'safe' but of course does nothing to sto...
I have a program where std::list is used.
The program uses threads which act on the std::list as producers and consumers.
When a message is dealt with by the consumer, it is removed from the list using pop_front(). But, during pop_front, there is a core dump.
The gdb trace is as below. could you help getting me some insights into this ...
Note that the order can go either way (erase first then push back, just that this way doesn't require creating a local reference to the object).
for ( GameObjItr gameObj = m_gameObjects.begin();
gameObj != m_gameObjects.end(); gameObj++ ) {
if ( *gameObj && *gameObj != gameObject ) {
const sf::FloatRect &otherObj = (...
I ran valgrind on my program because of a segfault I can't figure out. It detected a problem here...
Address 0x75c7670 is 0 bytes inside a block of size 12 free'd
at 0x4024851: operator delete(void*) (vg_replace_malloc.c:387)
by 0x805F6D8: std::list<Object*, std::allocator<Object*>::remove(O
bject* const&) (new_allocator.h:95)
T...
Hello!
I have got a std::list< std::pair<std::string,double> >, which I know is sorted according to the std::string element.
Since I would like to do a lot of std::find_if based on the std::string element, I believe a std::map<string,double,MyOwnBinaryPredicate> with lower_bound and upper_bound would be more adequate.
The fact is tha...
In C++0x, what I want would be:
std::list<std::string> colours = {"red", "blue", "green", "grey", "pink", "violet"};
What's the easiest way in standard, non-0x C++?
...
Hi!
I have been using advance on some iterators, but I am afraid of a possible leapfrog above end(). I would like to make sure my iterators stay between the bounds, I thought of the distance but it seems it does not return what I would be expecting (non-positive values when iterators overpass end()). How would you make sure there is no ...
How can I create std::list with a fixed element count?
...
Hi, gang. First, a high-level description of the problem & approach.
I have a list containing images and pixel locations in each image - a list of lists. I want to pick n items at random from that list of images and for each image I want to iterate over k random pixel locations. I want to do this in parallel. For each processed pixel, I...