Thread: Telling a shared_ptr not to delete object?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by Kernel Sanders View Post
    Doesn't that defeat the purpose of a shared_ptr though?
    That's an excellent question. If you want an object to exist after the last reference to it has gone away, then it doesn't sound like shared_ptr is the type to be using for it.
    Last edited by whoie; 08-15-2008 at 06:53 PM.

  2. #2
    Algorithm engineer
    Join Date
    Jun 2006
    Posts
    286
    I guess I could always create my own class, or even just add a counter directly into the image class. shared_ptr seems to be a class of quite low weight complexity, so it wouldn't be hard to reproduce it.
    Come on, you can do it! b( ~_')

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by TriKri View Post
    I guess I could always create my own class, or even just add a counter directly into the image class. shared_ptr seems to be a class of quite low weight complexity, so it wouldn't be hard to reproduce.
    What about auto_ptr? I believe it has a release member function that basically releases the memory from automatic destruction. You could carry it around in the auto_ptr until you hand it off, "release it," to the SDL system for management.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using this as synchronization object
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 03-22-2008, 07:49 AM
  2. synchronization object choosing
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 03-22-2008, 04:33 AM
  3. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  4. Deleting object after list removal (C++ visual studio)
    By RancidWannaRiot in forum Windows Programming
    Replies: 2
    Last Post: 10-20-2005, 06:06 PM
  5. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM