dimanche 8 mars 2015

template equivalent of BOOST_STRONG_TYPEDEF?

BOOST_STRONG_TYPEDEF provides a means of creating new types out of old ones - like typedef, but it actually provides a new typedef which the compiler can recognize for overloading functions, etc.


Unfortunately, it doesn't appear that BOOST_STRONG_TYPEDEF supports templates:



template <class element>
BOOST_STRONG_TYPEDEF(vector<element>, List<element>);


does not compile. Is there any way to make this work, or a somewhat light weight workaround?


(Of course, I should point out typedef doesn't support templates either, but in C++11 you can use alias declarations to accomplish the same thing).


Aucun commentaire:

Enregistrer un commentaire