Auto pointer for unsigned char array?
<p>I'd need a class like std::auto_ptr for an array of unsigned char*, allocated with new[]. But auto_ptr only calls delete and not delete[], so i can't use it.</p>

<p>I also need to have a function which creates and returns the array. I came out with my own implementation within a class ArrayDeleter, which i use like in this example:</p>

<pre><code>#include &lt;Utils/ArrayDeleter.hxx&gt;

typedef Utils::ArrayDeleter&lt;unsigned char&gt; Bytes;

void f()
{
  // Create array with new
  unsigned char* xBytes = new unsigned char[10];
  // pass array to constructor of ArrayDeleter and
  // wrap it into auto_ptr
  return std::auto_ptr&lt;Bytes&gt;(new Bytes(xBytes));
}

...
// usage of return value
{
  auto_ptr&lt;Bytes&gt; xBytes(f());
}// unsigned char* is destroyed with delete[] in destructor of ArrayDeleter
</code></pre>

<p>Is there a more elegant way to solve this? (Even using another "popular" library)</p>
