title: Adding functionality to a handle wrapper
body: <p>I have a C++ RAII class for managing Win32 HANDLEs using boost::shared_ptr&lt;> that looks a bit like this:</p>
  
  <pre><code>namespace detail {
  struct NoDelete { void operator()( void* ) {}; };
  }; // namespace detail
  
  template&lt; typename HANDLE_TYPE, typename HANDLE_DELETER &gt;
  class CHandleT
  {
  public :
      explicit CHandleT( HANDLE_TYPE handle, bool delete_on_release = true )
      {
          if( delete_on_release )
              handle_ = Handle( handle, HANDLE_DELETER() );
          else
              handle_ = Handle( handle, detail::NoDelete() );
  
      };
  
      operator HANDLE_TYPE() const { return static_cast&lt; HANDLE_TYPE &gt;( handle_.get() ); };
  
  protected:
      typedef boost::shared_ptr&lt; void &gt; Handle;
      Handle handle_;
  
  }; // class CHandleT
  
  struct DeallocateHandle
  {
      void operator()( void* handle ) { ::CloseHandle( handle ); };
  };
  
  typedef CHandleT&lt; HANDLE, DeallocateHandle &gt; CHandle;
  </code></pre>
  
  <p>I would like to extend it such that instead writing:</p>
  
  <pre><code>CHandle my_handle( ::CreateEvent( NULL, FALSE, FALSE, NULL ) );
  ::SetEvent( my_handle.get() );
  </code></pre>
  
  <p>I could write:</p>
  
  <pre><code>CEvent my_event( NULL, FALSE, FALSE, NULL );
  my_event.SetEvent();
  </code></pre>
  
  <p>Would the best way to do that be to use the CHandle class as a member of a CEvent class? </p>
  
  <pre><code>class CEvent
  {
  public:
      explicit CEvent( LPSECURITY_ATTRIBUTES lpEventAttributes = NULL,
                       BOOL bManualReset = TRUE,
                       BOOL bInitialState = FALSE,
                       LPCTSTR lpName = NULL, 
                       bool delete_on_release = true ) :
          handle_( new CHandle( ::CreateEvent( lpEventAttributes, 
                                                bManualReset, 
                                                bInitialState, 
                                                lpName ),
                                 delete_on_release ) )
      {
      };
  
      BOOL SetEvent()
      {
          _ASSERT( NULL != handle_ &amp;&amp; NULL != handle_.get() );
          return ::SetEvent( handle_.get() );
      };
  
  private:
      boost::shared_ptr&lt; CHandle &gt; handle_;
  }; // class CEvent
  </code></pre>
  
  <p>Or, is there a better way? (Note that I still want to maintain the copy semantics of the CHandle given by boost::shared_ptr&lt;>.</p>
  
  <p>Thanks,
  PaulH</p>