Why not use pointers and avoid the copy constructors?
#include <iostream>
#include <map>
#include <TH2D.h>
void test(){
const double tdcmin = -850, tdcmax = -350;
const int ntdcbins = 250;
std::map<pair<int, int>, TH2D*> myMap;
for (int i = 1; i<=47; i=i+2) {
myMap[std::make_pair(i,i+1)] = new TH2D (Form("t%d_vs_t%d",i,i+1),
Form("t%d_vs_t%d",i,i+1),ntdcbins, tdcmin, tdcmax, ntdcbins, tdcmin, tdcmax);
}
for(map<pair<int, int>, TH2D*>::const_iterator it = myMap.begin(); it != myMap.end(); ++it) {
std::cout << it->first.first << " " << it->first.second << " " << it->second->GetTitle() << "\n";
}
map<pair<int, int>, TH2D*>::const_iterator res;
res = myMap.find( std::make_pair(1,2) );
if(res != myMap.end()) {
res->second->Fill(1.,2.);
cout << res->second->GetTitle() << "\n";
}
}
EDIT @behrenhoff explains what is happening below.