Search code examples
qtshared-ptr

Cannot initialize shared_ptr


I've shared_ptr <QMap < T , X > * > shared_ and I'm trying to initialize it like this:

shared_t = new QMap < T , X >();

but I'm getting error:

    c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\shared_ptr_base.h:762: error: cannot  
 convert 'QMap<boost::filesystem3::path, Qt::CheckState>*' to 'QMap<boost::filesystem3::path,    
   Qt::CheckState>**' in initialization

How am I supposed to initialize this ptr? Please note that I do need pointer to map as a type stored in shared_ptr


Solution

  • The type in the template parameter has to be the value type itself, not a pointer to it:

    shared_ptr <QMap<T, X> > shared_t;