title: Specify integral template argument of constructor template inside a class template
body: <p>I am creating a <code>std::tuple</code> equivalent for a <code>union</code> (instead of a <code>struct</code>). To do so, I also added a constructor template, where the first template argument is <code>size_t idx</code>, to initize the idx<sup>th</sup> element of the <code>union</code>. Moreover, there is another <code>variadic template</code> to specify what the argments of the actual type constructor are.</p>
  
  <p>Unfortunately, I can't seem to specify the <code>idx</code> template argument when calling the constructor, and it is also not implied (as it is not part of the argument list). Is there any way around this? How can I specify a <code>size_t</code> contructor template argument?</p>
  
  <p>Example code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  
  template&lt;typename T&gt;
  struct Foo
  {
      T d_val;
      size_t d_other_val;
      template&lt;size_t idx&gt;
      Foo(T val)
      {
          d_val = val;
          d_other_val = idx;
      }
  };
  
  
  int main() {
      Foo&lt;double&gt; f = Foo&lt;4&gt;(2.6);
  
      std::cout &lt;&lt; f.d_val &lt;&lt; " " &lt;&lt; f.d_other_val &lt;&lt; '\n';
  }
  </code></pre>
  
  <p>Source: <a href="http://ideone.com/UeBvF5" rel="nofollow">http://ideone.com/UeBvF5</a></p>
  
  <p>Of course, the 4 is matched on the class template, and not the constructor template. Is this fixable? Note that idx should be a compile time thing, and not a normal constructor argument. Although in this example, that would be the trivial solution.</p>
  
  <p>PS: the problem of course is, that in general constructor templates are implied by the arguments with which the constructor is called. Implicit specification is to the best of my knowledge not possible for the idx template argument.</p>