title: Template arguments are invalid (unique pointer)
body: <p>I am trying to make an N-dimensional array class that is dynamically resizable. My templated class has the signature <code>ndarray&lt;typename data_type, int dimensions&gt;</code>. To hold the array I want to use a unique pointer class member to hold a templated vector of the types <code>std::vector&lt;type_t&gt;</code> for 1D, <code>std::vector&lt;std::vector&lt;type_t&gt;&gt;</code> for 2D, <code>std::vector&lt;std::vector&lt;std::vector&lt;type_t&gt;&gt;&gt;</code> for 3d ect...</p>
  
  <p>The unique pointer will have a different signature depending on the number of dimensions. I wanted to have the class constructor for ndarray to set the signature of the unique pointer and use <code>new</code> to make the new vector but I would need an <code>auto</code> member variable to be set to  a vector of the type of the member variable which doesn't work. My current aproach is to use a templated function that returns an object of the type the array needs to be, <code>template&lt;typename data_type&gt; auto dimension_helper(int dimensions)</code> and then set the unique pointer signature like this <code>std::unique_ptr&lt;decltype(&lt;data_type&gt;dimension_helper(dimens))&gt; array</code>. This also does not work, giving me the errors template argument 1 is invalid and template argument 2 is invalid inside the unique pointer. </p>
  
  <p>What can I do to make my existing code work, or is there a better way at approaching the problem in a similar way?</p>
  
  <p>Code samples</p>
  
  <p>header</p>
  
  <pre><code>#ifndef ND_H_
  #define ND_H_
  #include &lt;cstring&gt;
  #include &lt;vector&gt;
  #include &lt;memory&gt;
  
  
  namespace NdArray{
      //use the following for dimension types 
      template&lt;typename T&gt;
      using d1 = std::vector&lt;T&gt;;
      template&lt;typename T&gt;
      using d2 = std::vector&lt;d1&lt;T&gt;&gt;;
      template&lt;typename T&gt;
      using d3 = std::vector&lt;d2&lt;T&gt;&gt;;
      template&lt;typename T&gt;
      using d4 = std::vector&lt;d3&lt;T&gt;&gt;;
      template&lt;typename T&gt;
      using d5 = std::vector&lt;d4&lt;T&gt;&gt;;
  
      template&lt;typename data_type&gt;
      auto dimension_helper(int dim);
  
  
  
      template&lt;typename data_type,int dimensions&gt;
      class ndarray{
              int dims;
              std::unique_ptr&lt;std::vector&lt;int&gt;&gt; xsub_spans;
  
          public:
              ndarray();
              ~ndarray();
              std::unique_ptr&lt;decltype(&lt;data_type&gt;dimension_helper(dimensions))&gt; array;
  
              template&lt;typename dat_type, int dim&gt;
              friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; , ndarray&lt;dat_type, dim&gt;&amp;);
      };
  
  }
  
  
  #endif
  </code></pre>
  
  <p>definitions so far</p>
  
  <pre><code>#include "nd.h" 
  using namespace NdArray;
  
  template&lt;typename data_type, int dimensions&gt;
  ndarray&lt;data_type, dimensions&gt;::ndarray(){
      dims = dimensions;
      array = new &lt;data_type&gt;dimension_helper(dimensions); 
  }
  
  template&lt;typename data_type&gt;
  auto dimension_helper(){
      switch (dims) {
          case 1 : {
              d1&lt;data_type&gt; type;
              return type;
              break;
          }
          case 2 : {
              d2&lt;data_type&gt; type;
              return type;
              break;
          }
          case 3 : {
              d3&lt;data_type&gt; type;
              return type;
              break;
          }
          case 4 : {
              d4&lt;data_type&gt; type;
              return type;
              break;
          }
          case 5 : {
              d5&lt;data_type&gt; type;
              return type;
              break;
          }
      }
  }
  </code></pre>