title: How can I write a custom deleter for an array managed by an unique_ptr?
body: <p>I am trying to find a way to write a custom deleter for a C array managed by a unique_ptr in a templated C++ class. I am purposefully trying to make the class leak memory by making the deleter do nothing. In the full class, some constructors allocate the memory and some do not - rather they make use of the memory in a raw byte buffer coming from a data stream. </p>
  
  <p>This is what I tried:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template &lt;class T&gt; class Matrix
  {
      private:
      int _size;
      std::unique_ptr&lt;T[]&gt; _array;
  
      public:
      Matrix(int size, void* data) : _size(size)
                                   , _array(NULL, [](T[]* p){})
      {
          _array.reset((T*)data);
      }
  };
  </code></pre>
  
  <p>The code does not compile, the error message is:</p>
  
  <pre><code>In file included from /tmp/test/test/test.cpp:9:
  /tmp/test/test/Matrix.h:22:55: error: expected ')'
                                   , _array(NULL, [](T[]* p){})
                                                        ^
  /tmp/test/test/Matrix.h:22:51: note: to match this '('
                                   , _array(NULL, [](T[]* p){})
                                                    ^
  1 error generated.
  </code></pre>