#include <vector>
template<class T>
using vec = std::vector<T>;
int main()
{
std::vector a{2,3};
// vec b{2,3}; // not going to work
}
我们仍然被迫使用宏吗?使用它们有很多缺点......
最佳答案
这是 CTAD 的一个已知问题 has been fixed in C++20
Are we still forced to use macros?
没有。如果您想要 CTAD,我建议使用 std::vector
关于c++ - 有没有办法拥有模板的别名并保留类模板参数推导?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58864886/