Update sprites from array

Thanks for all these replies. So I looked through some code on a few projects that I am working on for where I could use array instead of vector. For my use I only found 4 places where I am using a vector with a fixed number of elements.

So I guess I should have suggested to the OP that an array was fine is he just had the 4 clouds and wasn’t going to have more or dynamically add them, etc.

Thanks for the lesson today! We all benefit from conversations like this.

Did you see the new Scott Meyers book coming in November: http://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996/ref=sr_1_1?ie=UTF8&qid=1412175000&sr=8-1&keywords=scott+meyers

Yeah. I just makes no sense using a dynamic container, if you don’t need it. They offer a lot of features, memory management and what not, you just don’t need anyway. It just wastes resources. This is not so important with all that CPU power today, but maybe if you are using embedded devices or need thread safe containers or concurrency.
There are only a few containers and scenarios, which are thread-safe.

Another point is the need of contiguous memory. Not every dynamic container does guarantee that: http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/

You’r welcome. Herb Sutter is always a good read.

Yeah. Was waiting on that book, as it will cover C++11 and C++14. The old books were not covering the new standards.

Every topic has some MUST READ books and bibles. Be it C++, graphics programming, network programming, engines, OS and what not.

I pre-ordered the Meyers book. What Sutter books do you think are good?

Also, this seems interesting: http://www.amazon.com/gp/product/1430266678/ref=pd_luc_mrairec_04_04_t_lh?ie=UTF8&psc=1

I never learned this aspect to much back in school…

Also, can you elaborate on this? Just so we can all ready which containers are thread-safe, etc. I saw this: http://stackoverflow.com/questions/7817364/are-there-any-concurrent-containers-in-c11

Also, when you quote the c++ standard, how are you doing this? Did you purchase it? Or are you using: https://github.com/cplusplus/draft

I guess I’m looking for a way to search it to obtain pieces.

The problem with the containers are the iterators. They are invalidated if you are modifying the container elements. E.g. thread 1 changes elements, while thread 2 iterates over them. You would need some locking on the container.
The containers implement different allocators, which have to be adopted to concurrency. It is not an easy task.
Dynamic containers are reallocated, when inserting elements. This is a problem, if thread a is writing into the container(and the container needs reallocation), but thread 2 iterates over the container. Pointers and memory addresses are invalidated at the reallocation, so you have to compensate for it.

If the threads just do read operations on the container, you don’t have a problem.
There are different implementations of the STL, which differ in thread-safety.

You can read about thread-safety and containers here:


I had access to the standards years ago.
If i need to quote something here and then, I just use the pdf versions of the drafts.

Search it? Just produce the pdfs or use the links in here:

the way i’ve coded it, the positions are applied just fine, the thing is, only the first sprite spawned is actualy getting updated ( moves)…