Can alias templates have default template parameters?

  alias, c++, language-lawyer, templates

The following code is very short, but causes different compilers to behave disagree:

#include <tuple>

template <typename T = int, typename... Ts>
using tpl = std::tuple<T, Ts...>;

tpl x; // I would assume this should be std::tuple<int>

Clang and MSVC say that template argument deduction doesn’t work for alias templates, ICC says that template arguments are missing, while GCC has an internal compiler error. I would normaly consider that an indication that alias templates do not undergo deduction – especially that according to cppreference they don’t (which I am aware is not an official resource and just a reference) – but I would like to be sure.

Is this code really ill-formed or are alias template default template arguments simply not yet implemented in these compilers? I thought that they were added in C++17 or C++20.

Source: Windows Questions C++

LEAVE A COMMENT