Thread: STL vs hand-coded

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Even virtuals don't take up space in the class instance; merely the vptr does. (That's for most C++ implementatons - in theory they're free to do something different.)

    However, I think sean meant member variables: the size tracker and the pointer to the heap memory, and possibly member variables of the allocator.

    for example, the 'sqrt()' function. if you've come up with a better/faster algorithm of finding the square root of a number, then by all means, use it! if not, just stick to the sqrt() function provided by the STL.
    sqrt() is part of the CRT, not the STL. That aside, it's rather unlikely that you come up with a faster sqrt() than the one you have, while keeping its precision.
    If you don't need that precision, it's a different story.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    However, I think sean meant member variables:
    Sure, whatever makes me sound smarter.

  3. #18
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Even virtuals don't take up space in the class instance; merely the vptr does. (That's for most C++ implementatons - in theory they're free to do something different.)

    However, I think sean meant member variables: the size tracker and the pointer to the heap memory, and possibly member variables of the allocator.
    On second thought, the program must take some hardisk space to store non-inlined member functions(and presumably the program or pieces of the program are read into memory). vector operations are pretty much always going to be inlined. They're take up code space, but only if they're called.

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I really, really don't think that the ~2kB I estimate a vector to use at the very maximum really matter.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Formatting Using STL
    By ChadJohnson in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2004, 05:52 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. STL or no STL
    By codec in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2004, 02:36 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM