C++ introduced class template argument deduction so instead of
std::array<int, 33> arr{1,2,3,...};
std::vector<float> vec{0.0, 0.1, 0.01, ...};
std::pair<int, float> pair {1, 1.1};
we can write cleaner code
std::array arr{1,2,3,...};
std::vector vec{0.0, 0.1, 0.01, ...};
std::pair pair {1, 1.1};
But, when we make a type alias with the same template parameters deduction fails for some reason
#include <array>
template<class T, size_t N>
array_alias = std::array<T, N>;
int main() {
array_alias array {1,2,3}; // expected array_alias<int, 3>
return 0
}
I've expected it will use same deduction method, but for some reason every compiler throws an error. What's the difference with alias template and class template and is there a way to make it work?