Suppose I have a method as such
void foo(const boost::shared_ptr<Pfoo>& rx)
{
myvector->push_back(rx);
}
I read that when a boost::shared_ptr is passed as a reference its reference count does not increase. Now what would happen in the above scenario if the actual ptr ran out of scope ?
When pass pointer by reference - no copy occured, no reference-counter incrementing.
myvector->push_back(rx);
Here, in vector will be pushed copy of rx
, not rx
, so, reference-counter will be incremented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With