title: Passing arrays/pointers as template parameters
body: <p>I'm trying to create a template function of the following sort:</p>
  
  <pre><code>template &lt;bool isHorizontal, float* kernel&gt;
  __global__ void smoothFilterColumns(const TwImageCUDA_Device* source, TwImageCUDA_Device* 
  destination)
  {
  // code...
  }
  </code></pre>
  
  <p>(Don't worry about the <code>__global__</code>; this is being implemented on CUDA.)</p>
  
  <p>Unfortunately, it won't allow me to create instances of this function like this:</p>
  
  <pre><code>float ptrKernel[] = {1, 2, 1};
  smoothFilterColumns&lt;true, ptrKernel&gt;(dxBuffer-&gt;cuda_image, dxOutput-&gt;cuda_image);
  </code></pre>
  
  <p>I've tried all sorts of <code>float*</code>s and <code>float[]</code>s, with and without the <code>const</code> modifier. Is it even possible to create a template of this sort?</p>
  
  <p>Thanks in advance.</p>
  
  <p>NB. The kernel is being passed as a template parameter and not a normal function parameter because that allows me to create more efficient code in CUDA by unrolling loops.</p>
  
  <p><strong>Update</strong> Pointers to floats work as template parameters with standard C++, but apparently there's no way to get them to work with CUDA device functions, since they expect pointers to device addresses and one cannot define those externally. If anyone got that to work, please let me know.</p>