Jump to content
  • Advertisement
Sign in to follow this  


This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

No. The Standard C++ Library is a cross-platform library, so it would be a little odd to provide a very platform-specific feature like that.

However, I believe you can use boost smart pointers and specify the clean-up function (CloseHandle or DeleteObject, depending on the type of handle). I haven't done this myself, yet, but someone recently corrected me in an earlier post, suggesting you could indeed do this.

Or you could quickly make your own, even. Here's a shoddy example, probably complete with bugs, compiler errors, and so forth, to give you an example:
class auto_handle
explicit auto_handle(HANDLE handle);

operator HANDLE ();

HANDLE mHandle;

auto_handle(const auto_handle& handle);
auto_handle& operator = (const auto_handle& handle);

explicit auto_handle::auto_handle(HANDLE handle) :


auto_handle::operator HANDLE ()
return mHandle;

auto_handle::auto_handle(const auto_handle& handle)

auto_handle& auto_handle::operator = (const auto_handle& handle)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!