Trailing class template arguments not deduced : <p>The code below fails to compile with gcc 7.1.0, which complains about providing the wrong number of template arguments in the second line of main. This version of GCC is <a href="https://gcc.gnu.org/projects/cxx-status.html" rel="noreferrer">supposed to implement</a> template argument deduction of class templates.</p>

<p>I think the compiler should be able to deduce the class template argument T2 for Bar, which means that I shouldn't have to explicitly specify both arguments (<code>Bar&lt;int, int&gt;</code>) given paragraph 17.8.1.3 of the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf" rel="noreferrer">C++17 draft</a> which says, <em>"Trailing template arguments that can be deduced (17.8.2) or obtained from default template-arguments may be omitted from the list of explicit template-arguments."</em></p>

<p>Am I wrong? Is the compiler wrong? Is this an oversight or a deliberate design?</p>

<pre><code>template &lt;typename T&gt;
struct Foo {
    Foo(T t) {}
};

template &lt;typename T1, typename T2&gt;
struct Bar {
    Bar(T2 t) {}
};

template &lt;typename T1, typename T2&gt;
void bar(T2 t) {}

int main(int argc, char **argv) {

    Foo(42); // Works

    Bar&lt;int&gt;(42); // Fails to compile with "wrong number of
                  // template arguments (1, should be 2)"

    bar&lt;int&gt;(42); // Works
}
</code></pre>
