3

This is OK:

template<typename T> void test1(T x) {}
void abbreviated_test1(auto x) {} // equivalent to above

But this is not:

template <typename T> struct matrix {};
template<typename T> void test2(matrix<T> x) {}
// try abbreviated form:
void abbreviated_test2(matrix<auto> x) {} // error: 'auto' not allowed in template argument

Is there a reason why? Are there plans to support more complex abbreviated function templates in the future?

yorel
  • 177
  • 8
  • "*Are there plans to support more complex abbreviated function templates in the future?*" I seriously doubt it. The reason why it is not supported is that it was rejected by the committee, but the relevant details may need to look through historical documents. – 康桓瑋 Nov 14 '21 at 17:10

0 Answers0