jeudi 3 janvier 2019

How to alias, declare, and initiate all together

I have cases which I make an alias to specific template instance. In my code previous to c++11, it was, for example:

typedef std::vector<std::string> My;

But I want to use the new language capabilities for making only one instance. That would be:

template class std::vector<std::string>;//in source file
extern template class std::vector<std::string>;//in header file
using My = std::vector<std::string>;//in header file

I have a long list of such typedef's in one header file (they are all in same context). Is there a way to do it without repeating each template 3 times?

Aucun commentaire:

Enregistrer un commentaire