title: C++ Template Ambiguity
body: <p>A friend and I were discussing C++ templates. He asked me what this should do:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;bool&gt;
  struct A {
      A(bool) { std::cout &lt;&lt; "bool\n"; }
      A(void*) { std::cout &lt;&lt; "void*\n"; }
  };
  
  int main() {
      A&lt;true&gt; *d = 0;
      const int b = 2;
      const int c = 1;
      new A&lt; b &gt; (c) &gt; (d);
  }
  </code></pre>
  
  <p>The last line in main has two reasonable parses. Is 'b' the template argument or is <code>b &gt; (c)</code> the template argument? </p>
  
  <p>Although, it is trivial to compile this, and see what we get, we were wondering what resolves the ambiguity?</p>