简体   繁体   中英

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:

Matrix getMatrixFromFile(std::string &path);

Is this possible given that M, N are not known at compile time?

The answer is no.

The templates parameters are used to create types at compile time based on the types passed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM