Thread: Are auto pointers any good?

  1. #1
    Registered User
    Join Date
    Oct 2005

    Are auto pointers any good?

    Hi guys,

    This is just a general programming practice question. I am embarking on a major project which entails a lot of number crunching over double precision floating point numbers using a linked tree structure as the basic object. It will probably do more than a trillion iterations over these structures.

    My question is, if I'm concerned with speed, should I go for traditional pointer allocation and deallocation? Or are the performance gains negligible compared to using auto pointers?

    I've never used them before, and I have occasionally forgotten to deallocate pointers, so if speed doesn't take a critical hit with auto pointers, I thought I might as well go ahead and use auto pointers to avoid memory leaks. If speed does suffer, I'll try to be more careful about my code.

  2. #2

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Speed takes absolutely no hit on most operations on most smart pointers, on any halfway decent compiler. In particular, there should be no performance hit at all in using std::auto_ptr. Even something as complicated as tr1::shared_ptr only has a performance hit on copying, never on dereferencing, which is really the only operation worth worrying about.
    All the buzzt!

    "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

  4. #4
    Registered User
    Join Date
    Oct 2005
    Thanks for the reassurance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 51
    Last Post: 02-09-2009, 04:35 PM
  2. Need some good information on Array, strings, and pointers
    By Sshakey6791 in forum C++ Programming
    Replies: 4
    Last Post: 11-30-2008, 02:16 AM
  3. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  4. Replies: 4
    Last Post: 12-10-2006, 06:08 PM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
Website Security Test