Std::map without default constructor

I’ve a class MatrixTool without a default constructor and I add it to a std::map

    m_matrix_tools.insert(make_pair(CENTRAL, MatrixTool(method, "")));
    m_matrix_tools.insert(make_pair(ANTICUT_UP, MatrixTool(method, "")));
    m_matrix_tools.insert(make_pair(ANTICUT_DOWN, MatrixTool(method, "")));
    m_matrix_tools.insert(make_pair(REVERSECUT_UP, MatrixTool(method, "")));
    m_matrix_tools.insert(make_pair(REVERSECUT_DOWN, MatrixTool(method, "")));

when I compile it everythings are ok, but when I compile the dictionary:


g++ MatrixToolSys.C -g -O2 -Wall -fPIC -I-pthread -m64 -I/gpfs/storage_4/users/home/proof/root/include -I../  -I../../PhotonAnalysisTools -c -o MatrixToolSys.o
* Matrix4 Building dictionary MatrixToolSys_Cint.C
cd .. && rootcint  -f  Matrix4/MatrixToolSys_Cint.C -c -I../PhotonAnalysisTools/ Matrix4/MatrixToolSys.h+
g++ -g -O2 -Wall -fPIC -I-pthread -m64 -I/gpfs/storage_4/users/home/proof/root/include -I../  -I../../PhotonAnalysisTools   -c -o MatrixToolSys_Cint.o MatrixToolSys_Cint.C
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_pair.h: In constructor ‘std::pair<_T1, _T2>::pair() [with _T1 = const MatrixToolSys::Sys, _T2 = MatrixTool]’:
/gpfs/storage_4/users/home/proof/root/include/TCollectionProxyInfo.h:165:   instantiated from ‘static void* ROOT::TCollectionProxyInfo::Type<T>::construct(void*, size_t) [with T = std::map<MatrixToolSys::Sys, MatrixTool, std::less<MatrixToolSys::Sys>, std::allocator<std::pair<const MatrixToolSys::Sys, MatrixTool> > >]’
/gpfs/storage_4/users/home/proof/root/include/TCollectionProxyInfo.h:369:   instantiated from ‘static ROOT::TCollectionProxyInfo* ROOT::TCollectionProxyInfo::Generate(const T&) [with T = ROOT::TCollectionProxyInfo::MapInsert<std::map<MatrixToolSys::Sys, MatrixTool, std::less<MatrixToolSys::Sys>, std::allocator<std::pair<const MatrixToolSys::Sys, MatrixTool> > > >]’
MatrixToolSys_Cint.C:150:   instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_pair.h:81: error: no matching function for call to ‘MatrixTool::MatrixTool()’
../Matrix4/MatrixTool.h:14: note: candidates are: MatrixTool::MatrixTool(unsigned int, std::string)
../Matrix4/MatrixTool.h:10: note:                 MatrixTool::MatrixTool(const MatrixTool&)
make: *** [MatrixToolSys_Cint.o] Error 1

Hi,

If you need to store this map in a ROOT file, the MatrixTool object will need to have a default constructor. If you do not need to store this map in a ROOT file, make sure that the I/O is disabled for any containing class or mark the data member which has the map type to be transient: std::map<int, MatrixTool> fMap; //!

Cheers,
Philippe.