C++17 supports
template argument deduction for class templates
.Please see www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0091r3.html for detailed background information.
However, the code below doesn't work as expected;
#include <utility>
template<typename T>
struct A
{
T x;
};
int main()
{
auto p = std::pair{ 1, 2 }; // ok, as expected.
auto a = A{ 0 };
//
// error : no viable constructor or deduction guide
// for deduction of template arguments of 'A'
//
}
My compiler is clang 5.0 with -std=c++1z
.
Why does template argument deduction for class templates
not work on a plain struct?