Errors when using std::map::insert


I’m trying to construct a map that takes as its key the run number and value the luminosity. I’m doing this using the following syntax

std::map < int, double> lumiMap; lumiMap.insert(make_pair(runTemp,lumiTemp));

where runTemp and lumiTemp are the current run number and luminosity under consideration, respectively. However, when running I get the following error

Error: Can't call map<int,double,less<int>,allocator<pair<const int,double> > >::insert(make_pair(runTemp,lumiTemp)) in current scope countMuonsPerRunD3PD.C:205:
Possible candidates are...
(in map<int,double,less<int>,allocator<pair<const int,double> > >)
*** Interpreter error recovered ***

I tried including

#ifdef CINT
#pragma link C++ class map<int, double >+;

but no luck.


what are the types of runTemp and luniTemp? For Cint they should be of type int and double for make_pair to produce the correct type of pair. If they are something else either adjust their types or cast them when creating the pair for filling.

I think “std::make_pair” is a templated function and you don’t have the corresponding CINT dictionary entry (note: it should work in ACLiC pre-compiled code without problems).

In interpreted code, try: gInterpreter->GenerateDictionary("std::map<int, double>", "map"); int runTemp = 1; double lumiTemp = 1.0; std::map<int, double> lumiMap; lumiMap.insert( std::pair<int, double>(runTemp, lumiTemp) );

BTW. CINT doesn’t care about “#pragma” directives in interpreted code.

Thanks. Compiling with ACLiC did the job.