//! \class SafeHandle //! Unique_ptr wrapper for WinAPI handles. class SafeHandle: public std::unique_ptr::type,void(*)( HANDLE )> { public: SafeHandle( HANDLE handle ): unique_ptr( handle, &SafeHandle::close ) { } operator HANDLE() { return get(); } const bool valid() const { return ( get() != INVALID_HANDLE_VALUE ); } private: static void close( HANDLE handle ) { if ( handle != INVALID_HANDLE_VALUE ) CloseHandle( handle ); } };