This is a discussion on std:vector:resize in gcc4.2 within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Elysia There is no need and it is a good thing to do so are two very ...
i would be extremely happy, because your code snippet looks so well ..
building GCC from source is no trivial matter, but it's not terribly difficult. I recently built 4.7 from the git repository on a couple of systems, and after installing a few extra necessary packages, it built without incident, and works great. I highly recommend upgrading to at least 4.5, if not 4.6 or 4.7. pre-built packages may even be available for mac.
thanks elkvis, i will give that a shot if i am having more time .. for now i just edited stl_vector.h .. quite dirty .. but the executable now builds and runs fine ..
Or, you know, you could do it the way they did before C++11:
Make a struct, add references to any members your lambda must be able to access, then initialize them in the constructor and overload operator () to act as a lambda.
OR BETTER YET:
Get rid of for_each and make a proper for loop. Seriously.
This way you don't have to upgrade (but you should!), or write long cryptic lines or code OR hack header files (which you should NEVER do!).