Given the following definition:
std::vector< std::pair< boost::shared_ptr<Class1>,
boost::shared_ptr<Class2> > >
PairsVector;
What is the best way to insert objects into the vector (without creating
them separately before inserting them)? I tried the following, but the
compiler complains that it cannot find a matching constructor:
PairsVector.push_back( std::pair< boost::shared_ptr<Class1>,
boost::shared_ptr<Class2> >( new Class1( NULL ),
new Class2( NULL ) ) );
On the other hand, this does compile:
PairsVector.push_back( std::pair< boost::shared_ptr<Class1>,
boost::shared_ptr<Class2> >( boost::shared_ptr<Class1>(new Class1( NULL )),
boost::shared_ptr<Class2>(new Class2( NULL )) ) );
Why won't the pair<> constructor accept the raw pointers and simply assign
them to the shared_ptr's?
- Dennis