I have been hitting my head against a brick wall for a bit and decided to submit and just post my error.
I have a template (shown below) that passes a std::map, which is inside a namespace. This compiles fine.
My problem occurs when trying to call the function template. I get the below error:
error: no matching function for call to
'getValuePointer(Muon*&, std::map<int, MET*, std::less<int>,
std::allocator<std::pair<const int, MET*> > >*&)'
What am I doing wrong?
Here is the template code:
#ifndef OBJECTMAPMATCH_H
#define OBJECTMAPMATCH_H
#include <map>
#include <utility>
#include <typeinfo>
#include <iostream>
#include <stdlib.h>
using namespace std;
namespace ObjectMapMatch {
template< class A, class B, class C >
C getValuePointer( A &x , map< B,C> &y )
{
if( y.find(x.Index()) != y.end() ){
return y.find(x.Index()).second;
}else{
cout << "ERROR:ObjectMapMatch::getValuePointer:Can not Find "
<< typeid(y).name() << " FOR " << typeid(x).name() << endl;
exit(1);
}
}
}
#endif
Here is an example call to the template function
C = ObjectMapMatch::getValuePointer<ClassC*, int, ClassD*>(A, B);
Where:
C is ClassC*
A is ClassC*
B is std::map<int,ClassD*>*
What am I doing wrong?