mardi 21 août 2018

Can I push a smart pointer to a list of smart pointers?

I have the following code:

class MarchingEvent
{
...
};

typedef std::list< std::shared_ptr<MarchingEvent> > Segment;

Can I do:

void myFunction(std::shared_ptr<MarchingEvent> A)
{
    Segment segment;
    segment.push_back( A ); // <- Questionable line.
}

Will my smart pointer be correctly incremented when pushing A to segment?

Aucun commentaire:

Enregistrer un commentaire