struct findCategoryByName
{
string name;
bool operator()(const category& a)
{
return (a.name == name);
}
};
struct findEntryByName
{
string name;
bool operator()(const entry* a)
{
return (a->name == name);
}
};
Is there a way to do this using template metaprogramming or something? I could always use a pointer to make it category* if that helps.
Creating a generic
findByNametemplate is as simple as replacing the specific type with a template parameter:(This assumes the parameter is passed by reference, but you could change it to take a pointer as the parameter if you prefer.)