Custom Vector template: Want to create erase/clear function

This is a discussion on Custom Vector template: Want to create erase/clear function within the C++ Programming forums, part of the General Programming Boards category; Alright, so it's been about a hour since I have been dwelling on this problem and I still do not ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    15

    Custom Vector template: Want to create erase/clear function

    Alright, so it's been about a hour since I have been dwelling on this problem and I still do not have a solid plan how to implement this.

    Here's the entire Vec class, it's a light version of the vector class:
    http://www.rafb.net/paste/results/wNErqi58.html

    I can read the entire code fine, but having difficulties of understanding its behavior/reaction, the cause of this problem I believe.

    Basically, I have to create the erase/clear function for this class, and every attempt I had gave me template related warnings.

    My plan was to create another Vec<T> object and use the copy algorithm to copy the elements of the original from its beginning to the element before the element that needs to be erased. Then I would use the push_back function to copy the rest of the data after that excluded iterator into the new Vec<T> object. Apparently it doesn't work >_>

    I don't need nor want a copy of the code, but more of a direction

    Oh yes, the warning is:
    warning C4996: 'std::_Uninit_copy' was declared deprecated
    You have used a std:: construct that is not safe. See documentation on how to use the Safe Standard C++ Library'


    This comes up everytime despite the fact that the code is directly from the book, Acclerated C++ except for the main().

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,474
    You are using Visual C++ 2005.
    That warning is a compiler specific warning. Microsoft decided to provide alternatives to some of the standard C++ functions that they consider dangerous and inform the coder of every instance when the so-called unsafe (and yet standard) functions are used.

    Click the warning and F1. The help system will instruct you on what exactly it means and how to turn it off.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    15
    Thanks, that warning casted doubt on my attempts of creating those member functions. Still, anyone can still provide some helpful tips

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    15
    It's been a day and now I understand how it feels for a person to understand what they were told and have no clue how to practically use it : p

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    15
    Well I solved it, however, I'm afraid there might be a memory leak specifically in the second allocated area that this function temporarly created.

    http://www.rafb.net/paste/results/2yBO9M96.html

    Is there?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 06:18 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Replies: 4
    Last Post: 11-07-2001, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21