为什么我不能在函数内声明模板类型别名?
#include <vector>
int main(){
//type alias deceleration:
template <typename T>
using type = std::vector<T>;
//type instantiation:
type<int> t;
}
错误: 模板声明不能出现在块作用域内
为什么我们必须将这些声明放在块作用域之外?
#include <vector>
//type alias deceleration:
template <typename T>
using type = std::vector<T>;
int main(){
//type instantiation:
type<int> t;
}