There are four maps in my program:
std::map< int, SigGen* > id_to_siggen_map;
std::map< int, std::vector< double > > id_to_ticks_map;
std::map< int, std::vector< double > > id_to_samples_map;
std::map< int, QListWidgetItem* > id_to_item_map;
and I want to write a template function that, given an id, can delete from any of the above maps an entry corresponding to that id, i.e.
int id = 4; //could be any other id number
delete_from_map(id, id_to_siggen_map); //deletes entry corresponding to id 4 from id_to_siggen_map
delete_from_map(id, id_to_ticks_map); //deletes corresponding entry from id_to_siggen_map
delete_from_map(id, id_to_samples_map);
delete_from_map(id, id_to_item_map);
What I have so far:
template <typename T>
void delete_from_map(int id, std::map< int, T > mymap){
for (auto it = mymap.begin(); it != mymap.end(); it++){
if(it->first == id){
mymap.erase(it);
break;
}
}
}
However, attempts to compile give me undefined reference error for each of the four maps. The error looks like the following:
error: undefined reference to `void DVis::delete_from_map<QListWidgetItem*>(int, std::map<int, QListWidgetItem*, std::less<int>, std::allocator<std::pair<int const, QListWidgetItem*> > >)'
What am I doing wrong here?