I don't have a lot of experience using templates but I'm trying to do template specialization based on enums with a function which returns different classes. Below is the sample code (or rather what I'm trying to accomplish):
class Foo {
// member variables
};
class Cat {
// member variables
};
enum MyType{ A, B, C};
// Header file
template<class T, MyType U> std_shared_ptr<T> process(U input);
// cpp file / implementation
template<,> std_shared_ptr<Foo> process(A)
{
}
template<,> std_shared_ptr<Cat> process(C);
{
}
Can someone help me in figuring out what I'm missing here or doing wrong? I tried searching it and found some solutions for handling enum types (Template specialization for enum), however, can't figure out how to put it together with a template return type in a function.
Aucun commentaire:
Enregistrer un commentaire