Thread: std:vector:resize in gcc4.2

  1. #16
    Registered User
    Join Date
    Feb 2012
    Quote Originally Posted by Elysia View Post
    There is no need and it is a good thing to do so are two very different things.
    You are kicking yourself and hurting everyone else by not updating.
    With latest GCC, you should be able to do

    std::vector<int> test;
    std::for_each(test.begin(), test.end(), [&test](int size) { test.resize(size); });
    Now compare that to what you are trying to do.
    but do you know a 100% if i just can update gcc on an apple and use it with xcode ?

  2. #17
    Registered User
    Join Date
    Feb 2012
    i would be extremely happy, because your code snippet looks so well ..

  3. #18
    Registered User
    Join Date
    Oct 2006
    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.

  4. #19
    Registered User
    Join Date
    Feb 2012
    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 ..

  5. #20
    Join Date
    Oct 2007
    Inside my computer
    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.

    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!).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. resize image
    By lamko in forum C Programming
    Replies: 22
    Last Post: 09-01-2011, 09:59 AM
  2. Resize Listview
    By mikeman118 in forum Windows Programming
    Replies: 4
    Last Post: 06-12-2008, 07:23 PM
  3. png Image Resize
    By bhupesh.kec in forum C Programming
    Replies: 3
    Last Post: 12-06-2007, 07:52 AM
  4. std::vector resize and Class copy constructor
    By pianorain in forum C++ Programming
    Replies: 3
    Last Post: 04-07-2005, 12:52 PM
  5. .resize
    By psyko369 in forum C++ Programming
    Replies: 2
    Last Post: 02-14-2002, 07:51 PM