The copy of the pointer is completely unnecessary: as long as the code is not sharing
shared_ptr
s among threads (which is really, really silly), taking ashared_ptr
argument by reference ensures it lives at least until the function finishes executing.Even if the copy was necessary, passing by reference to immediately make a copy is a pessimisation as it forbids moves. Don't pass
shared_ptr
by reference if you're going to copy it Don't passshared_ptr
by reference if you're going to copy it.The pointer in the vector will be destroyed by
erase
, there's no need to manuallyreset
anything.A predicate that mutates its argument is bound to raise eyebrows. Depending on the semantics of
setParent
it may or may not be problematic, but it is something I'd avoid if I could.
The copy of the pointer is completely unnecessary: as long as the code is not sharing
shared_ptr
s among threads (which is really, really silly), taking ashared_ptr
argument by reference ensures it lives at least until the function finishes executing.Even if the copy was necessary, passing by reference to immediately make a copy is a pessimisation as it forbids moves. Don't pass
shared_ptr
by reference if you're going to copy it.The pointer in the vector will be destroyed by
erase
, there's no need to manuallyreset
anything.A predicate that mutates its argument is bound to raise eyebrows. Depending on the semantics of
setParent
it may or may not be problematic, but it is something I'd avoid if I could.
The copy of the pointer is completely unnecessary: as long as the code is not sharing
shared_ptr
s among threads (which is really, really silly), taking ashared_ptr
argument by reference ensures it lives at least until the function finishes executing.Even if the copy was necessary, passing by reference to immediately make a copy is a pessimisation as it forbids moves. Don't pass
shared_ptr
by reference if you're going to copy it.The pointer in the vector will be destroyed by
erase
, there's no need to manuallyreset
anything.A predicate that mutates its argument is bound to raise eyebrows. Depending on the semantics of
setParent
it may or may not be problematic, but it is something I'd avoid if I could.
The copy of the pointer is completely unnecessary: as long as the code is not sharing
shared_ptr
s among threads (which is really, really silly), taking ashared_ptr
argument by reference ensures it lives at least until the function finishes executing.Even if the copy was necessary, passing by reference to immediately make a copy is a pessimisation as it forbids moves. Don't pass
shared_ptr
by reference if you're going to copy it.The pointer in the vector will be destroyed by
erase
, there's no need to manuallyreset
anything.A predicate that mutates its argument is bound to raise eyebrows. Depending on the semantics of
setParent
it may or may not be problematic, but it is something I'd avoid if I could.