In java generic, when I want to ensure that the type of some generic class must inherit a class, I can code as below:
public class MyHandler<T extends Serializable> {}
Which means that T must extends/implements the class/interface Serializable, otherwise, the compiler will generate an error.
How to get the same thing in C++11?
I mean, if I code C++11 as below:
template<typename T>
class MyHandler {}
In this piece of code, T can be any class. If I want to tell the class users that T must inherit the class boost::archive::text_oarchive (just like <T extends Serializable> in Java), what could I do?
Aucun commentaire:
Enregistrer un commentaire