Originally a computational scientist, with skills in high performance computing, I transitioned to software engineering as an independent contractor, specialising in C++.
Wow - I didn't realise that make_shared can implement an intrusive shared pointer. I guess it doesn't have to, according to the standard, but it makes sense as an optimisation.
I usually use weak_ptrs to break cycles in object graphs - and this still works, because the weak_ptrs will be destroyed during the object destructor, meaning the memory deallocation will still happen, just not necessarily at the same time as the destructor is called.
What other uses do people use weak_ptrs for?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Wow - I didn't realise that make_shared can implement an intrusive shared pointer. I guess it doesn't have to, according to the standard, but it makes sense as an optimisation.
I usually use weak_ptrs to break cycles in object graphs - and this still works, because the weak_ptrs will be destroyed during the object destructor, meaning the memory deallocation will still happen, just not necessarily at the same time as the destructor is called.
What other uses do people use weak_ptrs for?