[英]Is it possible to have a templated type not known at compile time
Suppose I have a class: 假设我有一堂课:
template <unsigned M, unsigned N, typename T = float>
class Matrix
{};
I want to read from a file which contains matrices of some unknown M,N and create the above type: 我想从包含某些未知M,N矩阵的文件中读取并创建上述类型:
Matrix getMatrixFromFile(std::string &path); 矩阵getMatrixFromFile(std :: string&path);
Is this possible given that M, N are not known at compile time? 鉴于在编译时不知道M,N,这可能吗?
The answer is no. 答案是不。
The templates parameters are used to create types at compile time based on the types passed. 模板参数用于在编译时根据传递的类型创建类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.